convert model and component to JS utilities

  • 1
  • Idea
  • Updated 4 years ago
I've been working with creating dynamic models and components. The tutorial does a good job of showing how it's done, but the process is repetitive and tedious for creating very little compared to the typical way creating a page.

Can you create utilities for converting models and components into the JS code? It would be very very useful.
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,704 Points 20k badge 2x thumb

Posted 4 years ago

  • 1
Photo of Moshe Karmel

Moshe Karmel, Champion

  • 8,646 Points 5k badge 2x thumb
Can you post the code that your using? It can probably be optimized in some way...
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,704 Points 20k badge 2x thumb
The code I'm using works fine. It's the creation of this code that I'd like a utility for.

var allModels = [];
    var currentTimeEntryModel = new skuid.model.Model();

    currentTimeEntryModel.objectName = 'Time_Entry_CB__c';
    currentTimeEntryModel.id = 'CurrentTimeEntry';
    currentTimeEntryModel.recordsLimit = 1;
    currentTimeEntryModel.fields = [
        { id: 'End_Time__c' },
        { id: 'Start_Time__c' },
        { id: 'Unique_Time_Entry__c' },
        { id: 'Unique_Time_Entry__r.Name' },
    ];
    
    currentTimeEntryModel.doQuery = true;

    currentTimeEntryModel.conditions = [
        { 
            enclosevalueinquotes: false,
            field: 'End_Time__c', 
            inactive: false,
            name: 'End_Time__c',
            operator: '=',
            type: 'blank', 
            value: 'null'
        }
        ,{
            enclosevalueinquotes: true,
            field: 'Time_Entry_for__c',
            inactive: false,
            mergefield: 'userid',
            operator: '=', 
            originalInactive: false,
            type: 'userinfo'
        }
    ];

    
    allModels.push(currentTimeEntryModel);
    // Initialize each of our Models
    // so that they have index maps created
    // and other internal guts,
    // then register them with Skuid
    // so that Skuid officially knows about them
    $.each(allModels,function(){
       // Register each of our Models with Skuid
        this.initialize().register();
    });
    // Load all Models --- this will:
    // (a) populate all metadata
    // (b) run the queries on the models
    
    skuid.model.load(allModels);
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
There was a sigh and grimace in the dev cave this morning.  Your idea is good,  but it just represents more we 'should' do.   Thanks for keeping them coming.   We'll keep the ideas in the backlog...