Taxons: Add support in the portal (UI still to be done).

This commit is contained in:
Molkobain
2018-09-26 17:13:55 +02:00
parent 1530bb89fe
commit 9397d1ac2e
11 changed files with 281 additions and 44 deletions

View File

@@ -32,6 +32,7 @@ use DBObjectSet;
use DBSearch;
use DBObjectSearch;
use InlineImage;
use ormTagSet;
use AttributeDateTime;
use AttributeTagSet;
use AttachmentPlugIn;
@@ -1123,13 +1124,13 @@ class ObjectFormManager extends FormManager
}
elseif ($oAttDef instanceof AttributeTagSet)
{
/** @var ormTagSet $oTagSet */
/** @var \ormTagSet $oTagSet */
$oTagSet = $this->oObject->Get($sAttCode);
if (is_null($oTagSet))
{
$oTagSet = new ormTagSet(get_class($this->oObject), $sAttCode);
}
$oTagSet->ApplyDelta($value);
$oTagSet->ApplyDelta(json_decode($value, true));
$this->oObject->Set($sAttCode, $oTagSet);
}
elseif ($oAttDef instanceof AttributeDateTime) // AttributeDate is derived from AttributeDateTime

View File

@@ -45,6 +45,7 @@
<link href="{{ app['combodo.absolute_url'] ~ 'css/font-awesome/css/font-awesome.min.css'|add_itop_version }}" rel="stylesheet">
{# - Misc libs #}
<link href="{{ app['combodo.portal.base.absolute_url'] ~ 'lib/typeahead/css/typeaheadjs.bootstrap.css'|add_itop_version }}" rel="stylesheet">
<link href="{{ app['combodo.absolute_url'] ~ 'css/selectize.default.css'|add_itop_version }}" rel="stylesheet">
<link href="{{ app['combodo.absolute_url'] ~ 'css/magnific-popup.css'|add_itop_version }}" rel="stylesheet">
<link href="{{ app['combodo.absolute_url'] ~ 'css/c3.min.css'|add_itop_version }}" rel="stylesheet">
{# - Bootstrap theme #}
@@ -85,6 +86,7 @@
<script type="text/javascript" src="{{ app['combodo.absolute_url'] ~ 'js/jquery.magnific-popup.min.js'|add_itop_version }}"></script>
<script type="text/javascript" src="{{ app['combodo.absolute_url'] ~ 'js/jquery.iframe-transport.js'|add_itop_version }}"></script>
<script type="text/javascript" src="{{ app['combodo.absolute_url'] ~ 'js/jquery.fileupload.js'|add_itop_version }}"></script>
<script type="text/javascript" src="{{ app['combodo.absolute_url'] ~ 'js/utils.js'|add_itop_version }}"></script>
<script type="text/javascript" src="{{ app['combodo.absolute_url'] ~ 'js/d3.min.js'|add_itop_version }}"></script>
<script type="text/javascript" src="{{ app['combodo.absolute_url'] ~ 'js/c3.min.js'|add_itop_version }}"></script>
<script type="text/javascript" src="{{ app['combodo.portal.base.absolute_url'] ~ 'lib/bootstrap/js/bootstrap.min.js'|add_itop_version }}"></script>
@@ -114,6 +116,9 @@
{# Typeahead files for autocomplete #}
<script type="text/javascript" src="{{ app['combodo.portal.base.absolute_url'] ~ 'lib/typeahead/js/typeahead.bundle.min.js'|add_itop_version }}"></script>
<script type="text/javascript" src="{{ app['combodo.portal.base.absolute_url'] ~ 'lib/handlebars/js/handlebars.min-768ddbd.js'|add_itop_version }}"></script>
{# Selectize for sets #}
<script type="text/javascript" src="{{ app['combodo.absolute_url'] ~ 'js/selectize.js'|add_itop_version }}"></script>
<script type="text/javascript" src="{{ app['combodo.absolute_url'] ~ 'js/jquery.itop-tagset-widget.js'|add_itop_version }}"></script>
{# Form files #}
<script type="text/javascript" src="{{ app['combodo.absolute_url'] ~ 'js/form_handler.js'|add_itop_version }}"></script>
<script type="text/javascript" src="{{ app['combodo.absolute_url'] ~ 'js/form_field.js'|add_itop_version }}"></script>
@@ -123,6 +128,7 @@
<script type="text/javascript" src="{{ app['combodo.portal.base.absolute_url'] ~ 'js/portal_form_handler.js'|add_itop_version }}"></script>
<script type="text/javascript" src="{{ app['combodo.portal.base.absolute_url'] ~ 'js/portal_form_field.js'|add_itop_version }}"></script>
<script type="text/javascript" src="{{ app['combodo.portal.base.absolute_url'] ~ 'js/portal_form_field_html.js'|add_itop_version }}"></script>
<script type="text/javascript" src="{{ app['combodo.portal.base.absolute_url'] ~ 'js/portal_form_field_tagset.js'|add_itop_version }}"></script>
{# UI Extensions JS, in an undefined order #}
{% if app['combodo.portal.instance.conf'].ui_extensions.js_files is defined %}
{% for js_file in app['combodo.portal.instance.conf'].ui_extensions.js_files %}

View File

@@ -0,0 +1,56 @@
//iTop Portal Form field TagSet
//Used for field containing tagset ...
;
$(function()
{
// the widget definition, where 'itop' is the namespace,
// 'portal_form_field' the widget name
$.widget( 'itop.portal_form_field_tagset', $.itop.portal_form_field,
{
// the constructor
_create: function()
{
this.element
.addClass('portal_form_field_tagset');
this.element.find('input[type="hidden"]').tagset_widget();
this._super();
},
// events bound via _bind are removed automatically
// revert other modifications here
_destroy: function()
{
this.element
.removeClass('portal_form_field_tagset');
this._super();
},
// _setOptions is called with a hash of all options that are changing
// always refresh when changing options
_setOptions: function()
{
this._superApply(arguments);
},
// _setOption is called for each individual option that is changing
_setOption: function( key, value )
{
this._super( key, value );
},
validate: function(oEvent, oData)
{
var oResult = { is_valid: true, error_messages: [] };
// Doing data validation
if(this.options.validators !== null)
{
// TODO
}
this.options.on_validation_callback(this, oResult);
return oResult;
}
});
});
light