mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-05-15 06:01:19 +00:00
select options in extension configuration can retain order (only attributedefinitions)
This commit is contained in:
parent
c815b0069d
commit
4d44774a7f
|
@ -762,12 +762,22 @@ if(($kkk = $this->callHook('getFullSearchEngine')) && is_array($kkk))
|
||||||
case "attributedefinitions":
|
case "attributedefinitions":
|
||||||
$objtype = empty($conf['objtype']) ? 0 : $conf['objtype'];
|
$objtype = empty($conf['objtype']) ? 0 : $conf['objtype'];
|
||||||
$attrtype = empty($conf['attrtype']) ? 0 : $conf['attrtype'];
|
$attrtype = empty($conf['attrtype']) ? 0 : $conf['attrtype'];
|
||||||
|
$order = empty($conf['order']) ? '' : $conf['order'];
|
||||||
$recs = $dms->getAllAttributeDefinitions($objtype, $attrtype);
|
$recs = $dms->getAllAttributeDefinitions($objtype, $attrtype);
|
||||||
if($recs) {
|
if($recs) {
|
||||||
echo "<select class=\"chzn-select\"".($allowempty ? " data-allow-clear=\"true\"" : "")." name=\"extensions[".$extname."][".$confkey."][]\"".(!empty($conf['multiple']) ? " multiple" : "").(!empty($conf['size']) ? " size=\"".$conf['size']."\"" : "")." data-placeholder=\"".getMLText("select_attrdef")."\" data-no_results_text=\"".getMLText('unknown_attrdef')."\" style=\"width: 100%;\">";
|
echo "<select class=\"chzn-select\"".($allowempty ? " data-allow-clear=\"true\"" : "").($order ? " order=\"".$order."\"" : "")." name=\"extensions[".$extname."][".$confkey."][]\"".(!empty($conf['multiple']) ? " multiple" : "").(!empty($conf['size']) ? " size=\"".$conf['size']."\"" : "")." data-placeholder=\"".getMLText("select_attrdef")."\" data-no_results_text=\"".getMLText('unknown_attrdef')."\" style=\"width: 100%;\">";
|
||||||
if($allowempty)
|
if($allowempty)
|
||||||
echo "<option value=\"\"></option>";
|
echo "<option value=\"\"></option>";
|
||||||
|
if($order == 'keep') {
|
||||||
|
foreach($selections as $selid) {
|
||||||
|
if($rec = $dms->getAttributeDefinition($selid)) {
|
||||||
|
echo "<option value=\"".$rec->getID()."\" selected data-subtitle=\"".htmlspecialchars(getAttributeObjectTypeText($rec).", ".getAttributeTypeText($rec))."\">".htmlspecialchars($rec->getName())."</option>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
foreach($recs as $rec) {
|
foreach($recs as $rec) {
|
||||||
|
if($order == 'keep' && in_array($rec->getID(), $selections))
|
||||||
|
continue;
|
||||||
echo "<option value=\"".$rec->getID()."\"";
|
echo "<option value=\"".$rec->getID()."\"";
|
||||||
if(in_array($rec->getID(), $selections))
|
if(in_array($rec->getID(), $selections))
|
||||||
echo " selected";
|
echo " selected";
|
||||||
|
|
|
@ -28,6 +28,12 @@ chzn_template_func = function (state) { /* {{{ */
|
||||||
return $newstate;
|
return $newstate;
|
||||||
}; /* }}} */
|
}; /* }}} */
|
||||||
|
|
||||||
|
function chzn_select_item(target, id) { /* {{{ */
|
||||||
|
var option = $(target).children('[value=' + id + ']');
|
||||||
|
option.detach();
|
||||||
|
$(target).append(option).change();
|
||||||
|
}; /* }}} */
|
||||||
|
|
||||||
function escapeHtml(text) { /* {{{ */
|
function escapeHtml(text) { /* {{{ */
|
||||||
var map = {
|
var map = {
|
||||||
'&': '&',
|
'&': '&',
|
||||||
|
@ -99,6 +105,11 @@ function initMost() { /* {{{ */
|
||||||
templateResult: chzn_template_func
|
templateResult: chzn_template_func
|
||||||
}); /* }}} */
|
}); /* }}} */
|
||||||
|
|
||||||
|
/* newly selected items will be appended to the end */
|
||||||
|
$('.chzn-select[order=keep]').on('select2:select', function (e) { /* {{{ */
|
||||||
|
chzn_select_item(e.target, e.params.data.id);
|
||||||
|
}); /* }}} */
|
||||||
|
|
||||||
$(".chzn-select-folder").select2({ /* {{{ */
|
$(".chzn-select-folder").select2({ /* {{{ */
|
||||||
theme: "bootstrap4",
|
theme: "bootstrap4",
|
||||||
width: 'resolve',
|
width: 'resolve',
|
||||||
|
|
|
@ -28,6 +28,12 @@ chzn_template_func = function (state) { /* {{{ */
|
||||||
return $newstate;
|
return $newstate;
|
||||||
}; /* }}} */
|
}; /* }}} */
|
||||||
|
|
||||||
|
function chzn_select_item(target, id) { /* {{{ */
|
||||||
|
var option = $(target).children('[value=' + id + ']');
|
||||||
|
option.detach();
|
||||||
|
$(target).append(option).change();
|
||||||
|
}; /* }}} */
|
||||||
|
|
||||||
function escapeHtml(text) { /* {{{ */
|
function escapeHtml(text) { /* {{{ */
|
||||||
var map = {
|
var map = {
|
||||||
'&': '&',
|
'&': '&',
|
||||||
|
@ -103,6 +109,11 @@ function initMost() { /* {{{ */
|
||||||
templateResult: chzn_template_func
|
templateResult: chzn_template_func
|
||||||
}); /* }}} */
|
}); /* }}} */
|
||||||
|
|
||||||
|
/* newly selected items will be appended to the end */
|
||||||
|
$('.chzn-select[order=keep]').on('select2:select', function (e) { /* {{{ */
|
||||||
|
chzn_select_item(e.target, e.params.data.id);
|
||||||
|
}); /* }}} */
|
||||||
|
|
||||||
$(".chzn-select-folder").select2({ /* {{{ */
|
$(".chzn-select-folder").select2({ /* {{{ */
|
||||||
theme: "bootstrap4",
|
theme: "bootstrap4",
|
||||||
width: 'resolve',
|
width: 'resolve',
|
||||||
|
|
Loading…
Reference in New Issue
Block a user