Improvements to selectization
This commit is contained in:
parent
54029c2941
commit
7dfff9f9ee
|
@ -1,11 +1,12 @@
|
||||||
/**
|
/**
|
||||||
* selectize one select widget. Substitute the actual id of the widget for `{{widget_id}}`.
|
* selectize one select widget. Substitute the actual id of the widget for `{{widget_id}}`,
|
||||||
|
* and the current value for {{widget_value}}.
|
||||||
*/
|
*/
|
||||||
$('#{{widget_id}}').selectize({
|
$('#{{widget_id}}').selectize({
|
||||||
valueField: 'id',
|
valueField: 'id',
|
||||||
labelField: 'name',
|
labelField: 'name',
|
||||||
searchField: 'name',
|
searchField: 'name',
|
||||||
options: [],
|
hideSelected: false,
|
||||||
create: false,
|
create: false,
|
||||||
|
|
||||||
load: function(query, callback) {
|
load: function(query, callback) {
|
||||||
|
@ -25,4 +26,4 @@ $('#{{widget_id}}').selectize({
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
})[0].selectize.setValue({{widget_value}}, true);
|
||||||
|
|
|
@ -266,8 +266,14 @@
|
||||||
farkey
|
farkey
|
||||||
"}}' {% ifequal record."
|
"}}' {% ifequal record."
|
||||||
(-> property :attrs :name)
|
(-> property :attrs :name)
|
||||||
" option." farkey "%}selected{% endifequal %}>"
|
" option." farkey "%}selected='selected'{% endifequal %}>"
|
||||||
(s/join " " (map #(str "{{option." (:name (:attrs %)) "}}") fs-distinct))
|
(s/join " " (map
|
||||||
|
#(str
|
||||||
|
"{{option."
|
||||||
|
(:name (:attrs %))
|
||||||
|
(if (= (-> % :attrs :type) "entity") "_expanded")
|
||||||
|
"}}")
|
||||||
|
fs-distinct))
|
||||||
"</option>{% endfor %}")]))
|
"</option>{% endfor %}")]))
|
||||||
|
|
||||||
|
|
||||||
|
@ -616,7 +622,8 @@
|
||||||
(> magnitude 2)
|
(> magnitude 2)
|
||||||
(embed-script-fragment
|
(embed-script-fragment
|
||||||
"resources/js/selectize-one.js"
|
"resources/js/selectize-one.js"
|
||||||
[["{{widget_id}}" (-> property :attrs :name)]]
|
[["{{widget_id}}" (-> property :attrs :name)]
|
||||||
|
["{{widget_value}}" (str "{{record." (-> property :attrs :name) "}}")]]
|
||||||
))))
|
))))
|
||||||
(children-with-tag entity :property #(= (-> % :attrs :type) "entity")))
|
(children-with-tag entity :property #(= (-> % :attrs :type) "entity")))
|
||||||
(if
|
(if
|
||||||
|
|
Loading…
Reference in a new issue