mirror of
https://github.com/cosmocode/dokuwiki-plugin-struct.git
synced 2025-08-06 10:24:17 +00:00
use data ttribute for autocompletion
this moves the whole field creation to a separate function and adds the full qualified column name as a data attribute. This is needed because we can not rely on the field's name to figure out the column name as it will be unrelated in bureaucracy use
This commit is contained in:
@ -13,6 +13,7 @@ use plugin\struct\meta\Assignments;
|
||||
use plugin\struct\meta\SchemaData;
|
||||
use plugin\struct\meta\ValidationException;
|
||||
use plugin\struct\meta\Validator;
|
||||
use plugin\struct\meta\Value;
|
||||
use plugin\struct\types\AbstractBaseType;
|
||||
|
||||
/**
|
||||
@ -220,11 +221,26 @@ class action_plugin_struct_entry extends DokuWiki_Action_Plugin {
|
||||
// posted data trumps stored data
|
||||
$field->setValue($postdata[$label]);
|
||||
}
|
||||
$html .= self::makeField($field, self::$VAR . "[$tablename][$label]");
|
||||
}
|
||||
$html .= '</fieldset>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the input field
|
||||
*
|
||||
* @param Value $field
|
||||
* @param String $name field's name
|
||||
* @return string
|
||||
*/
|
||||
static public function makeField(Value $field, $name) {
|
||||
$trans = hsc($field->getColumn()->getTranslatedLabel());
|
||||
$hint = hsc($field->getColumn()->getTranslatedHint());
|
||||
$class = $hint ? 'hashint' : '';
|
||||
$colname = $field->getColumn()->getFullQualifiedLabel();
|
||||
|
||||
$name = self::$VAR . "[$tablename][$label]";
|
||||
$input = $field->getValueEditor($name);
|
||||
|
||||
// we keep all the custom form stuff the field might produce, but hide it
|
||||
@ -234,17 +250,14 @@ class action_plugin_struct_entry extends DokuWiki_Action_Plugin {
|
||||
$hide = '';
|
||||
}
|
||||
|
||||
$html .= "<label $hide>";
|
||||
$html = '';
|
||||
$html .= "<label $hide data-column=\"$colname\">";
|
||||
$html .= "<span class=\"label $class\" title=\"$hint\">$trans</span>";
|
||||
$html .= "<span class=\"input\">$input</span>";
|
||||
$html .= '</label>';
|
||||
}
|
||||
$html .= '</fieldset>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// vim:ts=4:sw=4:et:
|
||||
|
11
helper/field.php
Normal file
11
helper/field.php
Normal file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Allows adding a struct field as a bureaucracy field
|
||||
*/
|
||||
class helper_plugin_struct_field extends helper_plugin_bureaucracy_field {
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -86,10 +86,7 @@ jQuery(function () {
|
||||
jQuery('input.struct_autocomplete').autocomplete({
|
||||
ismulti: false,
|
||||
source: function (request, cb) {
|
||||
var name = this.element.attr('name');
|
||||
name = name.substring(19, name.length - 1);
|
||||
name = name.replace('][', '.');
|
||||
|
||||
var name = jQuery(this.element[0]).closest('label').data('column');
|
||||
var term = request.term;
|
||||
if (this.options.ismulti) {
|
||||
term = extractLast(term);
|
||||
|
Reference in New Issue
Block a user