perak / kitchen-examples

Meteor Kitchen examples
164 stars 115 forks source link

Empty default option in select fields #24

Open exside opened 9 years ago

exside commented 9 years ago

Hi Perak,

first of all, thank you for your awesome work, it's truly amazing!

then the actual question:

Is there a possibility to define an additional first select menu option with a default value when defining a field as select and joining in some collection to display the items of that joined collection as select options (like in the Invoices example where you can select a Customer for an Invoice)?

I tried inserting null or "" in the default value field, but that didn't help. By default the select menu is always having the first item in the collection selected as the value (with no way to NOT have a value).

Any hints on this?

The template that generates the select menu is:

            <div class="form-group  field-owner">
                <label for="owner">
                    Owner
                </label>
                <div class="input-div">
                    <select class="form-control" name="owner" data-type="string">
                        {{#each admin_users}}
                        <option value="{{_id}}" {{optionIsSelected ../admin_project.owner _id}}>
                            {{profile.name}}
                        </option>
                        {{/each}}
                    </select>
                    <span id="help-text" class="help-block">
                    </span>
                    <span id="error-text" class="help-block">
                    </span>
                </div>
            </div>

looking at the #each section, there doesn't seem to be anything that is evaluated to look for a default value...sure I could add a custom input template here right? But who knows, maybe there is an easier way =)...

A general question regarding custom templates: When building the app directly via meteor-kitchen http://www.meteorkitchen.com/api/getapp/json/<appid> <appdir>, where is the input file downloaded to, e.g. what would be the location to put the folder for the custom input files?

perak commented 9 years ago

Hi Lukas,

yes, it is possible: please define field's "input_items" array. Static items will be shown at the top followed by items from the collection. On Sep 9, 2015 04:56, "Lukas Zahnd" notifications@github.com wrote:

Hi Perak,

first of all, thank you for your awesome work, it's truly amazing!

then the actual question:

Is there a possibility to define an additional first select menu option with a default value when defining a field as select and joining in some collection to display the items of that joined collection as select options (like in the Invoices example where you can select a Customer for an Invoice)?

I tried inserting null or "" in the default value field, but that didn't help. By default the select menu is always having the first item in the collection selected as the value (with no way to NOT have a value).

Any hints on this?

— Reply to this email directly or view it on GitHub https://github.com/perak/kitchen-examples/issues/24.

exside commented 9 years ago

Awesome, though they would override the items from the collection!!

Any hint to the second question?

"A general question regarding custom templates: When building the app directly via meteor-kitchen http://www.meteorkitchen.com/api/getapp/json/ , where is the input file downloaded to, e.g. what would be the location to put the folder for the custom input files?"

Thanks a lot and keep up the good work!

perak commented 9 years ago

Hi Lukas,

So you are using GUI... well, file is downloaded into system temp directory (usually "/tmp/" on Mac & Linux), but that directory is not a good place to put anything (directory is erased by operating system on next boot).

What you can do is to create shell script that will download file into your (any) local directory where you keep external files, and executes meteor-kitchen, something like this:

(pseudo code)

curl http://www.meteorkitchen.com/api/getapp/json/ > your_directory/my_app.json meteor-kitchen your_directory/my_app.json output_directory

On Wed, Sep 9, 2015 at 1:27 PM, Lukas Zahnd notifications@github.com wrote:

Awesome, though they would override the items from the collection!!

Any hint to the second question?

"A general question regarding custom templates: When building the app directly via meteor-kitchen http://www.meteorkitchen.com/api/getapp/json/ , where is the input file downloaded to, e.g. what would be the location to put the folder for the custom input files?"

Thanks a lot and keep up the good work!

— Reply to this email directly or view it on GitHub https://github.com/perak/kitchen-examples/issues/24#issuecomment-138880595 .

exside commented 9 years ago

Hi Perak,

thanks for the clarification! I decided to save the input file locally in the parent dir of the project, which works fine and is probably a better idea regarding including custom-components that are stored locally anyways...

Right now, another question / problem came up, I have a setup similar to the invoices examples, where a parent object has child objects (e.g. an invoice has invoice items), but these child objects again have their own child objects. The problem is, that I cannot figure out how to make the list items in the data-view (items page inside detail view for an invoice of invoices example) clickable, so that there is another detail view where I could display the childs child items. I tried specifying another details page besides items, insert and edit and set the details route for the inner page (items), but the list rows are still not clickable...do I miss something or asked differently, what defines that a data-view item is clickable (for detail view) additionally to being editable and deletable?

EDIT: Ignore me...just built the app from the wrong input file^^

perak commented 9 years ago

@exside DataView is clickable if component of type "dataview" have "details_route" defined. Also, if you define "edit_route" you'l have "pencil" icon (edit) and if you define "insert_route" you'l have "insert" button.

perak commented 9 years ago

Structure should be something like this (pseudo code)

- top_level_page
  - components
    - top_level_dataview
  - pages
    - details_page
      - components
        - details_dataview
      - pages
        - sub_details_page
          - components
            - sub_details_dataview
perak commented 9 years ago

Or, maybe better example, more similar to "invoices" example:

- top_level_page
  - components
    - top_level_dataview ("details_route": "top_level_details_page")
  - pages
    - top_level_details_page ("force_yield_subpages: true" will cause "second_level_details_page" to be always shown at the bottom)
      - components
        - top_level_details_form
      - pages
        - second_level_details_page
          - components
            - second_level_dataview ("details_route": "third_level_details_page")
          - pages
            - third_level_details_page ("force_yield_subpages: true" will cause "fourth_level_details_page" to be always shown at the bottom)
              - components
                - third_level_details_form
              - pages
                - fourth_level_details_page
                  - components
                    - fourth_level_dataview
perak commented 9 years ago

important: I just realized what else can be your problem: you need to properly pass route params to "edit_route", "details_route" etc. and also, if route doesn't exists, Meteor's <a href="{{pathFor 'non_existing_route'}}> will not show any error - simply, result will be link without href: <a href="">. And this can be reason why your dataview is not "clickable".

perak commented 9 years ago

(I got the same problem with mater-detail-subdetail-subsubdetails... etc., what we need here is better GUI, because big json looks like nightmare and current GUI is even worst :( )

exside commented 9 years ago

=), thanks for the hints, the issue was that I built the app from an old version of the input file...all your points are correct though! a) details route needs to be defined and route_params need to be passed (catched me a few times =D)!

I think the whole project could profit from a "duplicate" functionality (besides the edit and delete ones...) that would make it easier to replicate existing objects without making the same mistakes again (which happened to me) and then just change what needs to be changed. And drag and drop would help as well, to reorganize the app if necessary, e.g. drag pages to another node etc. instead of going to the json, finding the right sections (including not copying too many or too little brackets =D) and move them elsewhere. But you know what, your tool is already a huge time saver, so I do not want to complain at all =)!

Or is there an elegant way to implement a duplicate functionality for data view on a global level?

perak commented 9 years ago

@exside al complaints are welcome (more than "good work") :)

yeah, new gui is about to be started as open source project. If you wish to contribute and be part of it - you're welcome. Stay tuned!

btw, we need "bad ass" front designer too, so if you are the one or know somebody who is ready to contribute: <3