Skip to main content
Skip table of contents

Funzioni e CRUD

La FUNZIONE è uno script che mi permette di eseguire servizi, comandi che possono avere o meno un’interfaccia utente (es. data entry, calcola l’esportazione di dati..)

E' al contempo complessa (perchè mi richiede di specificare le proprietà di ogni elemento) ma per lo stesso motivo è anche "potente", in quanto per esempio mi permette di visualizzare un grafico, una tabella, una dashboard..

Il CRUD è una funzione, sviluppata nello specifico su una classe, che contiene dei comandi; più semplice rispetto alla "funzione primitiva", per cui lo script finale risulta più leggibile; mi permette di creare, leggere, modificare e cancellare una classe di Vibecode.

Vibecode prende la function crud e genera in automatico (temporaneamente) la funzione primitiva e la relativa vista sulla classe di riferimento.

Esempio classe kLanguage:

CRUD

CODE
crud name(fLanguage) classname(kLanguage) loaddefault(true) vieworder(field(code) direction(asc))
crudfield name(id) title(id) mandatory(false) insert(protect) update(protect) view(true) viewhide(true)
// kLanguage
  crudfield name(Code) search(true)
  crudfield name(Description) search(true)
  crudsectionbegin title(Remark) property(Remark)
    crudfield name(Remark.Text) view(false)
  crudsectionend
  crudfield name(VibsCode)
  crudfield name(Visible)
  crudfield name(IsoCode6391)

Funzione primitiva generata da Vibecode

CODE
function name(fLanguage) title(Language) classes(kLanguage) parameters() usemodel(true)
action name(init)
form name(FilterfLanguage) title(Language Filter) class(kLanguage) modality(selector) width(200) height(150) position(top) searchpanel(true)
   formfield name(fLanguagecode) title(Code) property(code)  sendtoserver(true)
   formfield name(fLanguagedescription) title(Description) property(description)  sendtoserver(true)
    actionlink name(actl_search_fLanguage) parent(FilterfLanguage) title(Search) source(none) action(search) icontype(search) enabled(true) visible(true) type(search)
  actionlink name(actl_ins_fLanguage) title(Add) parent(FilterfLanguage) source(none) visible(true) icontype(new) action(act_ins_fLanguage) type(new)
  endform
endaction
  action name(search)
    viewlist name(vl_fLanguage) title(Language) loadDefault(false) enabled(true) visible(true) format(default) customizable(true) customviewclass(kLanguage) customviewbaseviewapp() customviewbaseviewname(_ViewfLanguage) processviewparams(searchpanel(&FilterfLanguage) order(field(code) direction(asc)) filter()) type(grid) grouped(false)
      viewlistitem name(vbid) bind(id) title(id)  type(data)  property(id)  groupingfunction()  InvalidateColumn()wordwrap(false) sortable(true) resizable(true) draggable(true) visible(false)  editproperty(id)
      viewlistitem name(vli_code) bind(code) title(Code)  type(data)  property(code)  groupingfunction()  InvalidateColumn()wordwrap(false) sortable(true) resizable(true) draggable(true) formatref(c1)  editproperty(code)
      viewlistitem name(vli_description) bind(description) title(Description)  type(data)  property(description)  groupingfunction()  InvalidateColumn()wordwrap(false) sortable(true) resizable(true) draggable(true) tooltip(true) formatref(c2)  editproperty(description)
      viewlistitem name(vli_vibscode) bind(vibscode)  type(data) visible(false) property(vibscode)   groupingfunction()  InvalidateColumn()
      viewlistitem name(vli_vibscodedecoded) bind(vibscodedecoded) title(Vibs Code)  type(data) property(ldecode(vibscode))   groupingfunction()  InvalidateColumn()wordwrap(false) sortable(true) resizable(true) draggable(true) formatref(c3)  editproperty(vibscode)
      viewlistitem name(vli_visible) bind(visible)  type(data) visible(false) property(visible)   groupingfunction()  InvalidateColumn()
      viewlistitem name(vli_visibledecoded) bind(visibledecoded) title(Visible)  type(data) property(ldecode(visible))   groupingfunction()  InvalidateColumn()wordwrap(false) sortable(true) resizable(true) draggable(true) formatref(c4)  editproperty(visible)
      viewlistitem name(vli_isocode6391) bind(isocode6391) title(IsoCode6391)  type(data)  property(isocode6391)  groupingfunction()  InvalidateColumn()wordwrap(false) sortable(true) resizable(true) draggable(true) tooltip(true) formatref(c5)  editproperty(isocode6391)
      viewlistitem name(vli_remark.id) bind(remark.id) title(Id)  type(data)  property(remark.id)  groupingfunction()  InvalidateColumn()wordwrap(false) sortable(true) resizable(true) draggable(true) visible(false)  editproperty(remark.id)
 actionlink name(actl_closefLanguage) parent(vl_fLanguage) title(Close) source(none) action(closecrud) icontype(close) enabled(true) visible(true) type(cancel)
  actionlink name(actl_view_fLanguage) title(View) parent(vl_fLanguage) source(row) visible(true) icontype(view) action(act_view_fLanguage) type(view)
  actionlink name(actl_ins_fLanguage) title(New) parent(vl_fLanguage) source(none) visible(true) icontype(new) action(act_ins_fLanguage) type(new)
  actionlink name(actl_upd_fLanguage) title(Edit) parent(vl_fLanguage) source(row) visible(true) icontype(edit) action(act_upd_fLanguage) type(edit) default(true)
  actionlink name(actl_del_fLanguage) title(Delete) parent(vl_fLanguage) source(selectedrows) enabled(true) visible(true) icontype(delete) action(act_del_fLanguage) type(delete)
  actionlink name(actl_dup_fLanguage) title(Duplicate) parent(vl_fLanguage) source(row) enabled(true) visible(true) icontype(copy) action(act_dup_fLanguage) type(duplicate)
  actionlink name(actl_csvimport_fLanguage) title(Csv Import) parent(vl_fLanguage) source(none) enabled(true) visible(true) icontype(import) action(act_csvimport_fLanguage) type(csvimport)
 actionlink name(actl_refreshfLanguage) parent(vl_fLanguage) title(Refresh) source(none) action(search) icontype(refresh) enabled(true) visible(true) type(new)
actionlink name(actl_cstmactShowLocationsAssociated) title(Ciao) parent(vl_fLanguage) source(rows) enabled(true) visible(true) icontype(search) action(actShowLocationsAssociated) type(search) icontype(view)
    endviewlist 
  endaction  
action name(show_form_fLanguage)
 form name(formfLanguage) title(Language) class(kLanguage) modality(managedata) readonly('&_readonly' == 'true')bind(getformfLanguage) usemodel(true) height(600)  width(600)showinfo(true)info(code,description) objectid('&vl_fLanguage_vbid')
   formfield name(vbid) title(id) property(id)  enabled(false) mandatory(false) validateonedit(false) forceupdate(false)
   formfield name(code) title(Code) property(code)  mandatory(true) validateonedit(false) forceupdate(false)
   formfield name(description) title(Description) property(description)  mandatory(false) validateonedit(false) forceupdate(false)
 formsection label(Remark) collapsible() status() visible() enabled() property(Remark)
   formfield name(remark.text) title(Remark) property(remark.text)  mandatory(false) validateonedit(false) forceupdate(false)
endformsection
   formfield name(vibscode) title(Vibs Code) property(vibscode)  mandatory(false) validateonedit(false) forceupdate(false)
   formfield name(visible) title(Visible) property(visible)  mandatory(false) validateonedit(false) forceupdate(false)
   formfield name(isocode6391) title(IsoCode6391) property(isocode6391)  mandatory(false) validateonedit(false) forceupdate(false)
actionlink name(fLanguage_actShowLocationsAssociated) title(Locations Associated) source(none) icontype(search) action() enabled(false) visible(true) type(otherinline)
   formfield name(createdby) title(Created BY) property(createdby)  enabled(false) visible(false) mandatory(false) validateonedit(false) forceupdate(false)
   formfield name(lastmodifiedby) title(Last Modified By) property(lastmodifiedby)  enabled(false) visible(false) mandatory(false) validateonedit(false) forceupdate(false)
   formfield name(createddate) title(Created Date) property(createddate)  enabled(false) visible(false) mandatory(false) validateonedit(false) forceupdate(false)
   formfield name(lastmodifieddate) title(Last Modified Date) property(lastmodifieddate)  enabled(false) visible(false) mandatory(false) validateonedit(false) forceupdate(false)
   formfield name(revisionnumber) title(Revision Number) property(revisionnumber)  enabled(false) visible(false) mandatory(false) validateonedit(false) forceupdate(false)
   formfield name(workflowstatus) title(Workflow Status) property(workflowstatus)  enabled(false) visible(false) mandatory(false) validateonedit(false) forceupdate(false)
   formfield name(ownedonrequest) title(Is owned on request) property(ownedonrequest)  enabled(false) visible(false) mandatory(false) validateonedit(false) forceupdate(false)
   formfield name(origin) title(Origin) property(origin)  enabled(false) visible(false) mandatory(false) validateonedit(false) forceupdate(false)
 formsection label(Custom Remark) collapsible(true) status(true) visible(true) enabled(true) property(Remark)
   formfield name(remark.id) title(Id) property(remark.id)  enabled(false) visible(false) mandatory(true) validateonedit(false) forceupdate(false)
endformsection
    actionlink name(actl_form_fLanguage_confirm) parent(formfLanguage) title(Save) source(none) icontype(save) action(act_upd_fLanguage_confirm) enabled(true) visible('&_readonly' != 'true') type(submit)  skipauth(true) params(ap_close(false) ap_operation(save))  style(sconfirm)
    actionlink name(actl_form_fLanguage_confirmclose) parent(formfLanguage) title(Save and close) source(none) icontype(confirm) action(act_upd_fLanguage_confirm) enabled(true) visible('&_readonly' != 'true') type(submit)  skipauth(true) params(ap_close(true) ap_operation(save)) default(true)  style(sconfirm)
    actionlink name(actl_form_fLanguage_confirmadd) parent(formfLanguage)  title(Save and Add) source(none) icontype(confirmadd) action(act_upd_fLanguage_confirm) enabled(true) visible(and(ne('&_readonly','true'),or(ne('&_crudoperation','update'),eq('&vl_fLanguage._lastrecord','true')))) type(submit)  skipauth(true) params(ap_close(false) ap_operation(insert)) default(true) style(sconfirm)
    actionlink name(actl_form_fLanguage_confirmnext) parent(formfLanguage)  title(Save and Next) source(none) icontype(confirmnext) action(act_upd_fLanguage_confirm) enabled(true) visible(and(ne('&_readonly','true'),eq('&_crudoperation','update'),eq('&vl_fLanguage._lastrecord','false'))) type(submit)  skipauth(true) params(ap_close(false) ap_operation(update)) default(true) style(sconfirm)
    actionlink name(actl_form_fLanguage_cancel) parent(formfLanguage) title(Cancel) source(none) icontype(cancel) action(act_upd_fLanguage_cancel) enabled(true) visible('&_readonly' != 'true') type(cancel)  skipauth(true)  
    actionlink name(actl_form_fLanguageclose) parent(formfLanguage) title(Close) source(none) skipauth(true)   icontype(cancel) action(act_upd_fLanguage_cancel) visible('&_readonly' == 'true') type(cancel)
  endform
  setvariable name(formfLanguage._crudoperation) value(&ap_operation)  scope(function)
  setvariable name(formfLanguage._readonly) value(&ap_readonly)  scope(function)
endaction
  action name(act_upd_fLanguage_confirm)  skipauth(true)  
    if cond('&_phantom' == 'false')
      update class(kLanguage) lockid(&_lockid) locksession(&_locksession)
    else
      insert class(kLanguage)
    endif
    refresh viewlist(vl_fLanguage) filter(field(id) eq('&_lastid'))
    if cond('&ap_close'== 'true')
      closeform name(formfLanguage)
    else
      if cond('&ap_operation' == 'insert')
          setvariable name(formfLanguage._crudoperation) value(insert) scope(function)
        createmodel name(getformfLanguage) viewlist(vl_fLanguage) viewname(_fLanguage_mainview)
        setformdefault form(formfLanguage)
      else
      	 if cond('&ap_operation' == 'update')
           setvariable name(formfLanguage._crudoperation) value(update)  scope(function)
      	  	selectnext viewlist(vl_fLanguage)
      	 endif
      	 servicecall name(getformfLanguage) service(processview) parameters(name(_fLanguage_mainview) filter(field(id) eq('&_lastid'))  lockid(&_lockid) locksession(&_locksession))
      endif
      updateform name(formfLanguage)
    endif
  endaction
  action name(act_upd_fLanguage_cancel)
    if cond('&_phantom' != 'true')
       unlock lockid(&_lockid)
    endif
    closeform name(formfLanguage)
  action name(act_view_fLanguage) 
     servicecall name(getformfLanguage) service(processview) parameters(name(_fLanguage_mainview) filter(field(id) eq('&vl_fLanguage_vbid')))
     callaction action(show_form_fLanguage) params(ap_readonly(true) ap_operation(view))
  endaction
  action name(act_ins_fLanguage) 
     createmodel name(getformfLanguage) viewlist(vl_fLanguage) viewname(_fLanguage_mainview)
     callaction action(show_form_fLanguage) params(ap_readonly(false) ap_operation(insert))
     setformdefault form(formfLanguage)
  endaction
  action name(act_upd_fLanguage)  default(true)
     servicecall name(getformfLanguage) service(processview) parameters(name(_fLanguage_mainview) filter(field(id) eq('&vl_fLanguage_vbid'))  lockid(&_lockid) locksession(&_locksession))
     callaction action(show_form_fLanguage) params(ap_readonly(false) ap_operation(update))
  endaction
  action name(act_dup_fLanguage) 
     servicecall name(getformfLanguage) service(processview) parameters(name(_fLanguage_mainview) filter(field(id) eq('&vl_fLanguage_vbid')) duplicate(true))
     callaction action(show_form_fLanguage) params(ap_readonly(false) ap_operation(duplicate))
  endaction
  action name(act_csvimport_fLanguage)
    execfunction app(core) function(fCrudCsvImport) title(Import) parameters(fp_classname(BD861A00-69A4-4B70-8C92-A5C411909CDC))
  endaction
action name(refresh_grid)
callaction action(search)
endaction
  action name(closecrud)
    closeform
  endaction
action name(act_del_fLanguage)
  setvariable name(tempvar) value(&vl_fLanguage.selected.code) scope(action)
  confirm title(Confirm delete) text(Are you sure you want to delete these records [%s] ?) textvalues(&tempvar)
  if cond('&_rsp'=='yes')
    delete class(kLanguage) id(&vl_fLanguage.selected.vbid) viewlist(vl_fLanguage)
  else
    message title(Operation Cancelled) text(Record has not been deleted) textvalues(&tempvar)
  endif
endaction
  action name(actShowLocationsAssociated)
message  title("ciao")
  endaction
endfunction

 

Vista generata da Vibecode

CODE
view name(_ViewfLanguage) class(kLanguage)  order(field(code) direction(asc)) filter() maxrecords(-1)
viewcolumn name(vbid) reference(id) function()
viewcolumn name(code) reference(code) function()
viewcolumn name(description) reference(description) function()
viewcolumn name(vibscodedecoded) reference(ldecode(vibscode)) function()
viewcolumn name(vibscode) reference(vibscode)  function()
viewcolumn name(visibledecoded) reference(ldecode(visible)) function()
viewcolumn name(visible) reference(visible)  function()
viewcolumn name(isocode6391) reference(isocode6391) function()
viewcolumn name(remark.id) reference(remark.id) function()

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.