apostrophecms-legacy / apostrophe-schemas

DEPRECATED - FOR APOSTROPHE 0.5 SITES ONLY - BUILT IN TO APOSTROPHE 2.X. Allows any object to have a schema of properties that can be edited in the browser, sanitized on the server and easily saved in Mongo. Schema types include text, select, tags, Apostrophe areas and singletons, and joins (one-to-one and many-to-many relationships), among others.
MIT License
3 stars 3 forks source link

Selects are not "enhanced" in join "relationship" fields. #7

Closed jsumnersmith closed 9 years ago

jsumnersmith commented 9 years ago

When adding a select as a relationship field for a join, the select is never enhanced thereby allowing the user to never select an option. Consequently, the joined items never save though no console error is shown on either the server or client side.

Here is the schema configuration:

{
      name: '_featuerdProjects',
      type: 'joinByArray',
      withType: 'project',
      idsField: 'projectIds',
      getOptions: {
        fields: { title: 1, slug: 1, thumbnail: 1 }
      },
      relationship: [
        {
          name: 'size',
          type: 'select',
          choices: [
            {
              label: 'Large (Two-Thirds)',
              value: 'large'
            },
            {
              label: 'Medium (One-Half)',
              value: 'medium'
            },
            {
              label: 'Small (One-Third)',
              value: 'small'
            },
          ]
        }
      ],
    }

And the resulting markup:

<ul data-list="" class="apos-selective-list">
  <li class="apos-fieldset-selective-item" data-item="" data-id="1" data-value="263481276172556131" data-label="Other Project">
    <div class="apos-ui-container apos-fieldset-selective-item-inner">
      <div class="apos-fieldset-selective-item-inner-bg apos-ui-btn apos-ui--dark">
        <span class="apos-remove" data-remove=""><i8 class="icon icon-remove"></i8></span>
        <span class="apos-selective-label" data-label="">Other Project</span>
      </div>
      <span class="apos-selective-extras">
        <label></label>
        <select name="jquerySelective[1][size]" data-extras="" data-selectize="" data-name="size">
          <option value="large" label="Large (Two-Thirds)">Large (Two-Thirds)</option>
          <option value="medium" label="Medium (One-Half)">Medium (One-Half)</option>    
          <option value="small" label="Small (One-Third)">Small (One-Third)</option>
        </select>
      </span>
    </div>
  </li>
</ul>
jsumnersmith commented 9 years ago

I see that my omission of "relationshipField" caused the saving issue, but the non-enhancement seems to stand as a bug.

boutell commented 9 years ago

Makes sense.

On Mon, Sep 7, 2015 at 8:08 PM, Joel Smith notifications@github.com wrote:

I see that my omission of "relationshipField" caused the saving issue, but the non-enhancement seems to stand as a bug.

— Reply to this email directly or view it on GitHub https://github.com/punkave/apostrophe-schemas/issues/7#issuecomment-138394453 .

THOMAS BOUTELL, DEV & OPS P'UNK AVENUE | (215) 755-1330 | punkave.com

boutell commented 9 years ago

Those guys are cloned and appended on the fly, so it makes sense that their own enhance call needs to happen.

We'll have to look at whether jquery selective already has an event after appending an item that we can use for this purpose. (Yes, I wrote it, but that doesn't mean I remember (; )

On Mon, Sep 7, 2015 at 9:20 PM, Tom Boutell tom@punkave.com wrote:

Makes sense.

On Mon, Sep 7, 2015 at 8:08 PM, Joel Smith notifications@github.com wrote:

I see that my omission of "relationshipField" caused the saving issue, but the non-enhancement seems to stand as a bug.

— Reply to this email directly or view it on GitHub https://github.com/punkave/apostrophe-schemas/issues/7#issuecomment-138394453 .

THOMAS BOUTELL, DEV & OPS P'UNK AVENUE | (215) 755-1330 | punkave.com

THOMAS BOUTELL, DEV & OPS P'UNK AVENUE | (215) 755-1330 | punkave.com

boutell commented 9 years ago

This is fixed. Opening a separate issue in hopes someone can figure out why the result is ugly.