perak / kitchen-examples

Meteor Kitchen examples
164 stars 115 forks source link

applying "helpers_code" & "template_rendered_code" for crud modal templates #49

Closed anthonymanzo closed 7 years ago

anthonymanzo commented 7 years ago

Hi, I haven't been able to apply "helpers_code" & "template_rendered_code" for crud items the way I can for other fields. I need this for the typeahead plugin (using https://github.com/sergeyt/meteor-typeahead). Here's how I have been implementing typeahead for other fields using the custom fields - In the component json - "template_rendered_code": "Meteor.typeahead.inject(); Meteor.subscribe('adusers');", "helpers_code": "\"adUsersPersonCode\":function(){ return adUsersPersonCode(); }, \"typeaheadSelectedDeptHeadName\":function(event, suggestion, datasetName){ typeaheadSelectedDeptHeadName(event, suggestion, datasetName); }, \"typeaheadSelected\":function(event, suggestion, datasetName){ typeaheadSelected(event, suggestion, datasetName); }, \"adUsersEmail\":function(){ return adUsersEmail(); }", Then in the field definition - `{ "name": "dept_head_person_code", "type":"string", "title": "Department Head Person Code", "required": true, "input": "custom", "input_template": "tt_name_person_code.html",

                    "show_in_dataview": false,
                    "show_in_read_only_form": false,
                    "exportable": true
                },  `

And the custom template - `

<div class="input-div">
    <input type="text" name="FIELD_NAME" value="FIELD_VALUE" class="form-control typeahead" placeholder="FIELD_TITLE" autocomplete="off" spellcheck="off" data-source="adUsersPersonCode" data-select="typeaheadSelectedDeptHeadName">
    <span id="help-text" class="help-block"></span>
    <span id="error-text" class="help-block"></span>
</div>

Again, question is how typeahead helpers and code can be done for the 'crud items'. Here is what my crud items look like in the kitchen json - { "name": "contacts", "title": "Contacts", "type":"array", "input":"crud", "array_item_type":"object",

                    "crud_fields":[
                        {
                            "name":"contact_type",
                            "title":"Contact Type",
                            "input":"select",
                            "input_items":[
                                {"value":"Admin","title":"Admin"},
                                {"value":"Science","title":"Science"},
                                {"value":"Financial","title":"Financial"}
                            ],
                            "required": true
                        },
                        {
                            "name":"contact_email",
                            "title":"Contact Email",
                            "input":"custom",
                            "type":"string",
                            "input_template": "tt_name_email.html",
                            "exportable":true
                        }
                    ],
                    "exportable": true,
                    "show_in_dataview": false
                },                  `

Thanks for your awesome project. -Tony Any suggestions? I have tried registering the helpers globaly for the modals but can't get it to work.

anthonymanzo commented 7 years ago

custom template code got cut off, here it is again:

<div class="form-group FIELD_GROUP_CLASS FIELD_ID">
    <label for="FIELD_NAME">FIELD_TITLE</label>
    <div class="input-div">
        <input type="text" name="FIELD_NAME" value="FIELD_VALUE" class="form-control typeahead" placeholder="someone@salk.edu" autocomplete="off" spellcheck="off" data-source="adUsersEmail" data-select="typeaheadSelected">
        <span id="help-text" class="help-block"></span>
        <span id="error-text" class="help-block"></span>
    </div>
</div>
perak commented 7 years ago

(put three backticks)

perak commented 7 years ago

@anthonymanzo Sorry, custom_template and template rendered code is not implemented for "CRUD" input. But, I'll se what I can do in next version.

anthonymanzo commented 7 years ago

Can I put the modal template rendered and helper somewhere else (client startup)? I’ve tried but Iron router or maybe blaze seems to be ignoring it.

On Dec 6, 2016, at 2:40 PM, Petar Korponaić notifications@github.com<mailto:notifications@github.com> wrote:

@anthonymanzohttps://github.com/anthonymanzo Sorry, custom_template and template rendered code is not implemented for "CRUD" input. But, I'll se what I can do in next version.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/perak/kitchen-examples/issues/49#issuecomment-265296435, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AH95W40VazRqSED_z2DRgeYpGJEuN2Y_ks5rFeRkgaJpZM4LF9eu.

perak commented 7 years ago

The best you can do with this is to create "custom component" for entire form containing CRUD field.

perak commented 7 years ago

@anthonymanzo Or see if you can tweak something in ~/.meteor-kitchen/templates/blaze/ui/bootstrap3/components/form.html (and form.js)

(be warned: your modifications will be overwritten after you install new version of meteor-kitchen).

anthonymanzo commented 7 years ago

Ok. Thanks.

On Dec 6, 2016, at 2:43 PM, Petar Korponaić notifications@github.com<mailto:notifications@github.com> wrote:

The best you can do with this is to create "custom component" for entire form containing CRUD field.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/perak/kitchen-examples/issues/49#issuecomment-265297166, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AH95WxX7kPFqyzWK6sLnOWTF-bu57mTUks5rFeUkgaJpZM4LF9eu.

perak commented 7 years ago

@anthonymanzo BTW, if you modify template and make this thing work, please let me know, so I'll include it into next version. TNX.

anthonymanzo commented 7 years ago

Cleaning up the spaces in a json validator did the trick. Closing issue. Thanks