User Tools

Site Tools


newdevs:angularclient:basicadmin

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
newdevs:angularclient:basicadmin [2025/03/28 12:21] slearynewdevs:angularclient:basicadmin [2025/04/02 15:59] (current) – syntax highlighting sleary
Line 16: Line 16:
 To render a combobox, set that field's options to customValues: myComboBoxEntriesArray: To render a combobox, set that field's options to customValues: myComboBoxEntriesArray:
  
 +<code html>
    [fieldOptions]="{    [fieldOptions]="{
     myFieldName1: {customValues: myComboBoxEntriesArray}     myFieldName1: {customValues: myComboBoxEntriesArray}
    }"    }"
 +</code>
  
 To render a custom template (with optional context arguments), set: To render a custom template (with optional context arguments), set:
  
 +<code html>
    [fieldOptions]="{    [fieldOptions]="{
      myFieldName1: {customTemplate: {template: myTemplateRefHashFor1}},      myFieldName1: {customTemplate: {template: myTemplateRefHashFor1}},
      myFieldName2: {customTemplate: {template: myTemplateRefHashFor2, context: {letVarName: myFieldName2ContextData}}}      myFieldName2: {customTemplate: {template: myTemplateRefHashFor2, context: {letVarName: myFieldName2ContextData}}}
    }"    }"
 +</code>
  
 for example: for example:
  
 +<code html>
    [fieldOptions]="{    [fieldOptions]="{
       event: {customTemplate: {template: eventTemplate}},       event: {customTemplate: {template: eventTemplate}},
Line 45: Line 49:
     </output>     </output>
    </ng-template>    </ng-template>
 +</code>
  
 Always use: Always use:
Line 56: Line 61:
 Use ''pcrud.retrieve()'' to fetch a row by its primary key: Use ''pcrud.retrieve()'' to fetch a row by its primary key:
  
 +<code JavaScript>
    pcrud.retrieve('aou', 1).then( org => console.log(org.shortname()) );    pcrud.retrieve('aou', 1).then( org => console.log(org.shortname()) );
 +</code>
    
 Use ''pcrud.search()'' to do a full query with a WHERE object (the second argument): Use ''pcrud.search()'' to do a full query with a WHERE object (the second argument):
  
 +<code JavaScript>
    pcrud.search('aou', {id : [1,2,3]}).then( orgs => console.log(orgs.length) );    pcrud.search('aou', {id : [1,2,3]}).then( orgs => console.log(orgs.length) );
 +</code>
  
 Use ''pcrud.search()'' with a third argument to add limit, order_by, and fleshing: Use ''pcrud.search()'' with a third argument to add limit, order_by, and fleshing:
  
 +<code JavaScript>
    pcrud.search('aou', {id : {'!=' : null}}, {limit : 10}).then( orgs => {    pcrud.search('aou', {id : {'!=' : null}}, {limit : 10}).then( orgs => {
      for (const org of orgs) {      for (const org of orgs) {
Line 71: Line 79:
      }      }
    } );    } );
 +</code>
  
- +  * Note that booleans are given as '''t''' or '''f''
-  * Note that booleans are given as 't' or 'f' +  * order_by is an object where the keys are the classnames and the values are strings with the field name, then a space, then the direction (''ASC'' or ''DESC'')
-  * order_by is an object where the keys are the classnames and the values are strings with the field name, then a space, then the direction (ASC or DESC)+
  
 Record notes example: Record notes example:
  
 +<code JavaScript [enable_line_numbers="true"]>
             const where = {             const where = {
               record: this.recId,                record: this.recId, 
Line 103: Line 112:
                     complete: this.emitNoteCount                     complete: this.emitNoteCount
                 }));                 }));
 +</code>
  
 ==== Fleshing ==== ==== Fleshing ====
  
-flesh_fields is an object where the keys are the classnames and the values are arrays of field names.+''flesh_fields'' is an object where the keys are the classnames and the values are arrays of field names. ''flesh'' is the recursion depth. 
 + 
 +Note that only pcrud is capable of fleshing; cstore is not. This means org unit settings cannot be fleshed! If you need to turn a user or OU ID into a name from settings data, you will need to add some logic to fetch those separately. 
 + 
 +==== IDL vs. Hash ==== 
 + 
 +Pcrud returns columns as functions: 
 + 
 +<code JavaScript> 
 +   org.shortname(); 
 +</code> 
 + 
 +To set a new value, pass the value as an argument: 
 + 
 +<code JavaScript> 
 +   note.value(new_note_text); 
 +</code> 
 + 
 +The IDL service has a toHash() method that can make this easier to work with if all you're doing is reading data: 
 + 
 +<code JavaScript> 
 +  idl.toHash(org_unit); 
 +  console.debug("Org unit is:", org_unit.shortname); 
 +</code> 
 + 
 +Note there is an option to flatten the data. 
 + 
 +As of 3.15, there is also a way to go from a hash back to a proper IDL object: 
 + 
 +<code JavaScript> 
 +  idl.fromHash(some_object, 'aou'); 
 +</code> 
 +   
 +The classname is the second argument. There is an optional third argument to convert booleans from '''t/f''' to ''true/false''
newdevs/angularclient/basicadmin.1743178912.txt.gz · Last modified: 2025/03/28 12:21 by sleary

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki

© 2008-2022 GPLS and others. Evergreen is open source software, freely licensed under GNU GPLv2 or later.
The Evergreen Project is a U.S. 501(c)3 non-profit organization.