Git Product home page Git Product logo

association_ui_selector's Introduction

Association UI for Symphony: Selector

Interface preview

Selector provides a search and select interface for associative Symphony fields. It works with core select boxes and tag lists as well as with Association fields.

Installation

  1. Upload Selector to your extensions folder.
  2. Enable Selector in the backend.
  3. Add an associative field to your section and choose one of the interface.

Please keep in mind that interface are only available in combination with dynamic values, if you are using default select boxes or tag lists.

Modes

There are two modes:

  • single select
  • multiple select

Sorting

Sorting is currently only available for Association fields.

Custom Captions

It’s possible to include markup in your related field in order to create more informative item captions. Selector bundles styles for text, image previews and emphasis. If you’d like to combine multiple field values into a single caption, please take a look at Reflection field.

Basic Reflection field expressions

You can create a second row with a standard <br />. Emphasized text will be displayed in grey. The Reflection field can access fields by entry/[fieldname]. For example:

{entry/title}<br/><em>{entry/upload/filename}</em>

If you want to display an image thumbnail you can make use of JIT. An image size of 35×35px works best. Using this Reflection field fork mentioned here, you can use {root} to create a dynamic URL:

<img src='{root}/image/2/35/35/5/{entry/upload/filename}' /> {entry/title}<br/><em>{entry/upload/filename}</em>
Reflection field with XSLT-utility

For more complex needs Reflection field lets you use an XSLT-utility. Here’s an example that formats biographic-data nicely based on if data is available in a specific entry. The Reflection field expression is simply:

{person}

The XSLT-utility needs to be in the workspace/utilities folder. It will be selectable in the Reflection field settings:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="data/entry">
    <data>
        <xsl:element name="person">
            <!-- Image thumbnail will only created if an image is present in the current entry -->
            <xsl:if test="image/filename">
                <!-- in order to make HTML-output work here wen need to warp the code elements in CDATA tags (thanks John :) -->
                <xsl:text><![CDATA[<img src=']]></xsl:text>
                <!-- I’m using a fork with a root-pseudo-parameter here. See https://github.com/animaux/reflectionfield/commit/2d10a65c5f9d0ed59f8c211863808471b90a3376 -->
                <xsl:value-of select="//params/root"/>
                <xsl:text>/image/2/35/35/5</xsl:text>
                <xsl:value-of select="image/@path"/>
                <xsl:text>/</xsl:text>
                <xsl:value-of select="image/filename"/>
                <xsl:text><![CDATA['/>]]></xsl:text>
            </xsl:if>
            <!-- Name expects first and last name to be mandatory -->
            <xsl:value-of select="firstname"/>
            <xsl:text> </xsl:text>
            <xsl:value-of select="lastname"/>
            <!-- Biographic data checks for existing data and adds an asterisk if only date of birth is present, and a cross if only date of death is present -->
            <xsl:if test="year_of_birth!= '' or year_of_death != ''">
                <xsl:text><![CDATA[<br/><em>]]></xsl:text>
                <xsl:choose>
                    <xsl:when test="year_of_birth != '' and year_of_death != ''">
                        <xsl:value-of select="year_of_birth/text()"/>–<xsl:value-of select="year_of_death/text()"/>
                    </xsl:when>
                    <xsl:when test="year_of_death = '' and year_of_birth != ''">
                        *<xsl:value-of select="year_of_birth/text()"/>
                    </xsl:when>
                    <xsl:when test="year_of_birth = '' and year_of_death != ''">
                        †<xsl:value-of select="year_of_death/text()"/>
                    </xsl:when>
                </xsl:choose>
                <xsl:text><![CDATA[</em>]]></xsl:text>
            </xsl:if>
        </xsl:element>
    </data>
</xsl:template>

</xsl:stylesheet>

Acknowledgement

The interface of Selector is based on Selectize by Brian Reavis bundled with the Symphony core.

This project has kindly been funded by Bernardo Dias da Cruz, Ben Babcock, Juraj Kapsz, Daniel Golbig, Vojtech Grec, Andrea Buran, Brendan Abbot, Roman Klein, Korelogic, Ngai Kam Wing, David Oliver, Patrick Probst, Mario Butera, John Puddephatt, Goldwiege, Andrew Minton, munki-boy, Martijn Kremers, Ian Young, Leo Nikkilä, Jonathan Mifsud and others. Read more.

If you like this extension, please consider a donation to support the further development.

PayPal Donation

association_ui_selector's People

Contributors

animaux avatar nathanhornby avatar nilshoerrmann avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

association_ui_selector's Issues

Feature Requests

Dear @hananils/association-ui-funders,

This week, work on the new Association UI will begin and we'd like to discuss a few conceptual things first. Hence, over the next days, we'll create issues and wiki entries here on Github and you are all invited to comment and give us your input.

Associations are a complex matter because each team, each project has different requirements. As you are sponsoring the development, we'd like to know more about your needs: please feel free to post feature requests here on this tracker so we can discuss ideas and prioritise features.

Thanks a lot for your support!

Association Editor 'Create New' doesn't allow editing

When I select the Association Editor: 'Editor: Create New' option, I can only create new Assosciation entries. The icons that allow editing existing entries disappear:

screen shot 2014-07-30 at 11 38 36 am

Is there a way to have both editing and creating new entries turned on?

A way to create custom captions?

With SSM we had the ability to generate custom captions from various fields:

<strong>{$caption}</strong> - {$image}

In some of our sections we have items with duplicate titles and need to differentiate them by date or ID (the left is Associations and the right is SSM):

screen shot 2014-08-01 at 4 20 36 pm

This was a great feature of SSM.

Arrow positioning

If you move the search bar up using the arrow key, the select icon is misaligned:

bildschirmfoto 2014-06-11 um 15 16 57

Placeholder reads 'None found.' when entry is removed.

If an associated entry is presently selected, removing it will cause the selector to display 'None found.' in the placeholder, when I'm assuming the expected placeholder would be the default 'Search and select…'.

Question: Pre-Filter Entries

Is there a way to add a filter to the possible selectable linked entries. E. g. only show entries with value X in field Y?

HTML markup in entry value when searching / filtering should be ignored

(I am not yet familiar with Selectize.js API) but at the moment, when searching against an item which contains HTML markup for custom display in the option / items list, the filtering appears to match words like “div”, “br”, etc.

A quick skim through the docs at https://github.com/brianreavis/selectize.js/blob/master/docs/usage.md#data_searching mentions this property:

  • dataAttr - The attribute from which to read JSON data about the option. - string - 'data-data’
  • searchField - an array of property names to analyze when filtering options - array - ['text']

Possibly either of these two or both might help? After of course passing clean values from PHP as data- attributes on the options els.

Tags - Existing Values filtering

It would be nice to allow the Association UI to pull in tags which have already been used within the field. Association UI works fine when tags fetch suggestions from another field/section, I'm not sure how much work it would be be to allow the 'Autocomplete' functionality on Existing Values.

Attaching Interfaces

This is actually more a feature request for the core, but I'd like to discuss the concept first before proposing it for the core: we need a unified approach to attach interfaces to a associative field (currently: select boxes, tag lists, SBL).

Symphony Core

Symphony already offers a global storage for associations in the database:

CREATE TABLE `sym_sections_association` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `parent_section_id` int(11) unsigned NOT NULL,
  `parent_section_field_id` int(11) unsigned DEFAULT NULL,
  `child_section_id` int(11) unsigned NOT NULL,
  `child_section_field_id` int(11) unsigned NOT NULL,
  `hide_association` enum('yes','no') COLLATE utf8_unicode_ci NOT NULL DEFAULT 'no',
  PRIMARY KEY (`id`),
  KEY `parent_section_id` (`parent_section_id`,`child_section_id`,`child_section_field_id`)
) ENGINE=MyISAM AUTO_INCREMENT=648 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

It would make sense to add another column that stores UIs by name (similar to how we store text formatters).

Additionally, it would be nice if Symphony provided a helper function for fields to create a UI selection in the section editor, e. g. ´buildAssociationUISelect()` (similar to buildFormatterSelect()).

In the publish area, Symphony should automatically reference the attached UI in a data attribute, e. g. data-ui. This is sufficient to find and adjust the backend using JavaScript. If authors of association interfaces would like alter the markup directly in the PHP, the existing delegates should be sufficient for this task.

Thoughts on this so far?

Association Interface Extensions

Extensions will have to announce their interfaces to the core, so the aforementioned interface selection can be populated automatically. Symphony currently makes use of two different concepts to add features with extensions:

  • autodiscovery by convention (e. g. text formatters are automatically loaded from a folder named text-formatters)
  • manual registration (see custom data source interfaces)

While I like the idea of autodiscovery, interfaces usualy consist of more than one file so the initial situation is different to text formatters.

I would be nice if @brendo could comment on this.

Odd width issue with placeholder on load

See attached. Chrome on OSX, the placeholder has an inline width of 4px, only on load. Once focus is given to the field and something typed, deleted, all is fine.
screen shot 2014-06-29 at 23 47 33

Coming along great by the way guys!

Umlauts in Search lead to JS-Error.

When using the search term schö for example an error is thrown and the search is not successful:

TypeError: undefined is not an object (evaluating 'a.length')

Markup in Existing Items

Existing items need to be reloaded because any markup provided by fields will not be available in the storage select box.

Association not retaining values on save if unlimited results is set in section editor

0.3.0 tag doesn't seem to retain selected values on save anymore.. it's intermittent so can't track it down.

Cache cleared
Symphony 2.4.1
Associations field 2.0
Association UI Selector 0.3.0

Also I noticed that there is an empty array returned as part of the association attributes on the body tag:

<body id="publish" class="section-handle-media page-edit id-5 associations-Array single">

Just so you are aware. Will investigate more.

maximum entries option behaviour

maximum entries option seems to limit the ammount of entries queried by the search, rather than limitiing the ammount of entries that can be selected. In result, sometimes some entries from the associated section cannot be found. Setting the number to a high value (e. g. 99999) fixes this.

Naming Conventions

As @twiro pointed out on the forum, we don't have a good naming convention for associative fields and surrounding extensions. There a basicly two concepts we have to take care of:

  • fields and
  • interfaces

Fields

We need fields to handle two perspectives: one from the child to the parent and one from the parent to its children. We already have Select Box Link Field which links entries to a single or multiple parents – it's actually the field you can setup any relationship with you need. What's missing is a field that shows references to the entry that link to the current one.

From a naming perspective the following would make sense in my eyes:

  • Association Field – a field to link sections
  • Association Reference Field – a field to display entry references in the linked section

This suggests to rename the Select Box Link Field.
A reference field should be create along with this project.

Interfaces

A lesson learned from existing relationship extension is the need to keep things simple and maintaineable. So I'd like to suggest to create separate extensions per user interface. Following the proposed field names, the following naming convention would make sense:

  • Association UI: Name of Interface

Thoughts?

Selectize is not defined error.

Uncaught ReferenceError: selectize is not defined aui.selector.publish.js:125 Uncaught ReferenceError: selectize is not defined aui.selector.publish.js:138 Uncaught ReferenceError: selectize is not defined aui.selector.publish.js:133 Uncaught ReferenceError: selectize is not defined aui.selector.publish.js:125 Uncaught ReferenceError: selectize is not defined aui.selector.publish.js:138 Uncaught ReferenceError: selectize is not defined aui.selector.publish.js:133 Uncaught ReferenceError: selectize is not defined aui.selector.publish.js:125 Uncaught ReferenceError: selectize is not defined aui.selector.publish.js:138 Uncaught ReferenceError: selectize is not defined aui.selector.publish.js:133 Uncaught ReferenceError: selectize is not defined aui.selector.publish.js:125 Uncaught ReferenceError: selectize is not defined aui.selector.publish.js:138 Uncaught ReferenceError: selectize is not defined aui.selector.publish.js:133 (anonymous function) aui.selector.publish.js:133

Getting the above in the console if I try and re-order the entries.

Associations field 0.5.3
Associations Selector 1.0.0 beta

Symphony Integration branch pulled and updated but still seeing same error.?

SSM migration

Since this is not directly a feature of the association-ui itself: At some point later it would be nice to have a way to migrate existing installations of subsection manager to the new association-ui ideally while retaining sort order.

This would not necessarily have to be a fully automatic script, a step-by-step instruction how to manipulate the database or something along these lines might do as well.

Call to a member function get() on a non-object

This is a preliminary bug report, because I haven't seen any negative consequences of it, but I've noticed a few of these crop up in a site's log:

2014/10/01 10:16:53 > Fatal Error: GenericExceptionHandler 1: Call to a member function get() on a non-object on line 15 of file [redacted]/extensions/association_ui_selector/content/content.get.php
2014/10/01 10:16:53 > Fatal Error: Javascript - TypeError: result.entry is undefined in file [redacted]/extensions/association_ui_selector/assets/aui.selector.publish.js on line 144

Unfortunately I don't know what triggered it because this would have been the clients' actions not mine.

Input placement on existing item

Another screenshot description for this one! Just a minor quirk.

screen shot 2014-06-30 at 15 42 42

When a selector has an existing value the input is pushed to the right (I assume to simulate the cursor being placed after the value), however this doesn't account for the icon (only visible when the association is saved), and so ends up with unexpected positioning. When the icon isn't there (before you save the entry) it's positioned as expected.

As a side issue, on a few occasions when bringing focus back to the input (when it has a value, before being saved) it doesn't trigger the text 'cursor' (blinky line), so it's not clear that the field has focus. This seems uncommon, but not rare - I haven't seen it happen on a saved entry, only an entry that has an association selected, but before the entry has been saved.

This is all in Chrome (35.0.1916.153) on OSX - in case relevant.

(I would look at fixing these myself by the way, but I'm poking around at data at the moment, not in any code, so felt it best to jot them down here in the meantime!)

Inconsistencies betweet single-select and multi-select

First off - awesome work! Finally had the chance to play around with the new association-ui-stuff and it's pretty calming to finally have this kind of functionality available in such a solid and flexible manner.

While the extension mostly worked like I expected I noticed the following inconsistencies in the styling which seemed a little irritating to me:

  1. The height of the field is different in single-select-mode than it is in multi-select-mode (FF31)
  2. A selected value in single-select-mode seems to have too much padding around it and looks quite different than a selected value in multi-select-mode (Couldn't this just get the same styling? Less padding + grey background?)

association-ui-selector-comparison-01

Two association fields in an entry pointing to the same section filter each other

I have a situation when an entry has two assoc. fields with different value meanings but they point to the same related section.

Issue: Happens I need to select the same value in each of the assoc. fields, but the value is globally filtered out from all assoc. fields options once selected in one of the assoc. fields.

Expected: Every assoc. field filters its still available values in its own scope.

Multiple items show same handle in UI

Create section with title and image
Input say three items in section (a,b,c)
Create another section with Association of first section but select both title and image
When choosing in the selection UI I see:
a, a, b, b, c, c
rather than I would expect
a, 1.jpg, b, 2.jpg, c, 3.jpg

Set Selectize.js maxOptions to match the field’s limit value

It’s a simple fix, not sure if it’s worth a PR or you can DYI :)
Happy to submit it as a PR if you prefer. Let me know.

I bumped into it with a 1800+ entry section. Thought it was caching, but turns out it’s Selectize’s default 1000 render limit.

This is probably best addressed with search-request-as-you-type, but for now this should do.

At: https://github.com/hananils/association_ui_selector/blob/master/assets/aui.selector.publish.js#L38

// Only added `maxOptions` line
// maxOptions: (limit === 0) ? 1000 : limit,

storage.selectize({
    maxOptions: (limit === 0) ? 1000 : limit,
    preload: (limit === 0),
    sortField: [{
        field: 'text', 
        direction: 'asc'
    }],
    // … rest of options / callbacks
})

Weird "Maximum entries" behavior when used with multiple sections

When I use an Association Field with the Association UI Selector, don't set a maximum entries value (which results in a "0"-setting when saved) and only link to one single section I get a list of all entries of the linked section in my entry form - no matter how much entries there are.

This behaviour makes me assume setting no maximum actually means not getting no entries but getting all entries instead. Which would be a useful feature that I always missed in SBL.

The problem I just noticed is that this assumption is proven wrong as soon as I link to a second section in the same association field - In that case I only get all results from the first linked section and none from the second when keeping an maximum entries value of 0.

As soon as I set the maximum entries to a value higher then the amount of entries in both section everything works fine again.

So on the one hand it would be great to have a consistent behavior of this feature in combination with the Association UI Selector, on the other hand it would be even better to bake this "no maximum = unlimited entries"-behavior directly into the Association Field and also include a small hint/description under the maximum entries input. Though the second aspect might be better posted as a separate issue in the AF-repo.

PHP 7.2 – $provides must be protected (as in class Extension)

I get the following error when trying to install this extensions in an PHP 7.2 environment:

Fatal error: Access level to extension_association_ui_selector::$provides must be protected (as in class Extension) or weaker in /is/htdocs/wp11073211_5RUB980JDE/www/symphony-php-72/extensions/association_ui_selector/extension.driver.php on line 0

Misplaced Arrows

The select arrows are misplaced, when a field allows multiple entries.

Donors

We were asked by @korelogic, if it was possible to add a link back to his site from the list of donors. We'd like to offer this to all @hananils/association-ui-funders.

Please post the name and link you'd like to be listed with in the readme here in this thread. Thanks!

Search broken with single select items

I have an association field with the following settings (Symphony 2.6.1):

bildschirmfoto 2015-04-08 um 10 13 23

Only a single item can be selected. If one is already selected I have no ability to search for another item to replace the currently selected one. I can only choose from the ones currently visible in the list. There is a blinking cursor but no way to input text:

bildschirmfoto 2015-04-08 um 10 13 43

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.