Adding List to Custom Modal

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • YNWA
    Junior Member
    • Nov 2024
    • 2

    Adding List to Custom Modal

    Code:
    define('custom:views/modals/my-dialog', ['views/modal', 'model'], (ModalView, Model) => {
      return class extends ModalView {
        className = 'dialog dialog-record'
        // language=Handlebars
        templateContent = `
            <div class="record no-side-margin">{{{record}}}</div>
        `;
        // If true, clicking on the backdrop will close the dialog.
        // Can be 'static', true or false.
        backdrop = true
        async setup() {
          // Action buttons
          this.buttonList = [{
            name: 'doSomething', // handler for 'doSomething' action is below
            text: this.translate('Some Action', 'labels', 'MyScope'), // button label
            style: 'danger',
            onClick: () => this.foo(),
          },
                             {
                               name: 'cancel',
                               label: 'Cancel',
                             },
                            ];
          const title = 'Distribute Leads'; // assuming it's passed from our parent view
          this.headerText = title;
    
          this.formModel = new Model();
          // Define fields
          this.formModel.setDefs({
            fields: {
              'someString': {
                type: 'varchar', // field type
                view: 'views/fields/varchar', // optional, to define custom view
                required: true, // field param
              },
              'someCheckbox': {
                type: 'bool',
              },
            }
          });
          // Load the collection asynchronously before initializing the list view
          const collection = await this.loadCollection();
          console.log('Collection => ', collection)
          this.createView('record', 'views/record/list', {
            collection: collection,
            type: 'listSmall',
    
          },
    
                          async loadCollection() {
                          const collection = await this.getCollectionFactory().create('User');
          await collection.fetch();
          return collection;
        }
        async foo() {
          //some function
        }
      }
    });​

    The createView does not create my list in the parent view is there something im missing, maybe a metadata/clientDefs declaration​
    Last edited by yuri; 12-03-2024, 01:13 PM.
  • yuri
    Member
    • Mar 2014
    • 8440

    #2
    The setup method is not async (unfortunately for backward compatibility reasons).
    If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

    Comment

    Working...