mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-18 06:48:50 +02:00
N°3067 - Cannot edit in place attributes with HTML editors
This commit is contained in:
@@ -975,7 +975,7 @@ HTML
|
||||
$oPage->add_ready_script(<<<JS
|
||||
$('#ac_create_{$this->iId}').dialog({ width: 'auto', height: 'auto', maxHeight: $(window).height() - 50, autoOpen: false, modal: true});
|
||||
$('#dcr_{$this->iId} form').removeAttr('onsubmit');
|
||||
$('#dcr_{$this->iId} form').on('submit.uilinksWizard', oACWidget_{$this->iId}.DoCreateObject);
|
||||
$('#dcr_{$this->iId} form').find('button[type="submit"]').on('click', oACWidget_{$this->iId}.DoCreateObject);
|
||||
JS
|
||||
);
|
||||
}
|
||||
|
||||
@@ -736,7 +736,10 @@ function ExtKeyWidget(id, sTargetClass, sFilter, sTitle, bSelectMode, oWizHelper
|
||||
var sId = $(this).attr('id');
|
||||
var editorInst = CKEDITOR.instances[sId];
|
||||
if (editorInst) {
|
||||
editorInst.updateElement();
|
||||
editorInst.destroy();
|
||||
}
|
||||
if ($('#'+sId).data('timeout_validate') != undefined) {
|
||||
clearInterval($('#'+sId).data('timeout_validate'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -71,102 +71,102 @@ $(function()
|
||||
this.toBeAdded = [];
|
||||
this.inputToBeRemoved = $('<input type="hidden" name="'+this.options.input_name+'_tbr" value="[]">');
|
||||
this.toBeRemoved = [];
|
||||
|
||||
|
||||
|
||||
|
||||
this.element
|
||||
.after(this.inputToBeCreated)
|
||||
.after(this.inputToBeDeleted)
|
||||
.after(this.inputToBeAdded)
|
||||
.after(this.inputToBeRemoved)
|
||||
.after('<span style="float:left"> <img src="../images/tv-item-last.gif"> ')
|
||||
.after(this.indicator);
|
||||
for(k in this.options.buttons)
|
||||
{
|
||||
.after(this.inputToBeDeleted)
|
||||
.after(this.inputToBeAdded)
|
||||
.after(this.inputToBeRemoved)
|
||||
.after('<span style="float:left"> <img src="../images/tv-item-last.gif"> ')
|
||||
.after(this.indicator);
|
||||
for (k in this.options.buttons) {
|
||||
this.element.after(this.oButtons[this.options.buttons[k]]).after(' ');
|
||||
}
|
||||
|
||||
this.element.find('.selectList'+this.id).bind('change', function() { me._updateButtons(); });
|
||||
this.oButtons['delete'].on('click', function() {
|
||||
$('.selectList'+me.id+':checked', me.element).each( function() { me._deleteRow($(this)); });
|
||||
|
||||
this.element.find('.selectList'+this.id).bind('change', function () {
|
||||
me._updateButtons();
|
||||
});
|
||||
this.oButtons['create'].on('click', function() {
|
||||
this.oButtons['delete'].on('click', function () {
|
||||
$('.selectList'+me.id+':checked', me.element).each(function () {
|
||||
me._deleteRow($(this));
|
||||
});
|
||||
});
|
||||
this.oButtons['create'].on('click', function () {
|
||||
me._createRow();
|
||||
});
|
||||
this.oButtons['remove'].on('click', function() {
|
||||
$('.selectList'+me.id+':checked', me.element).each( function() { me._removeRow($(this)); });
|
||||
this.oButtons['remove'].on('click', function () {
|
||||
$('.selectList'+me.id+':checked', me.element).each(function () {
|
||||
me._removeRow($(this));
|
||||
});
|
||||
});
|
||||
this.oButtons['add'].on('click', function() {
|
||||
this.oButtons['add'].on('click', function () {
|
||||
me._selectToAdd();
|
||||
});
|
||||
|
||||
|
||||
this._updateButtons();
|
||||
},
|
||||
|
||||
|
||||
// called when created, and later when changing options
|
||||
_refresh: function()
|
||||
{
|
||||
_refresh: function () {
|
||||
this._updateButtons();
|
||||
},
|
||||
// events bound via _bind are removed automatically
|
||||
// revert other modifications here
|
||||
_destroy: function()
|
||||
{
|
||||
_destroy: function () {
|
||||
this.element
|
||||
.removeClass('itop-directlinks');
|
||||
.removeClass('itop-directlinks');
|
||||
},
|
||||
// _setOptions is called with a hash of all options that are changing
|
||||
_setOptions: function()
|
||||
{
|
||||
_setOptions: function () {
|
||||
// in 1.9 would use _superApply
|
||||
this._superApply(arguments);
|
||||
},
|
||||
// _setOption is called for each individual option that is changing
|
||||
_setOption: function( key, value )
|
||||
{
|
||||
_setOption: function (key, value) {
|
||||
// in 1.9 would use _super
|
||||
this._superApply(arguments);
|
||||
|
||||
if (key == 'fields') this._refresh();
|
||||
|
||||
if (key == 'fields') {
|
||||
this._refresh();
|
||||
}
|
||||
},
|
||||
_updateButtons: function()
|
||||
{
|
||||
_updateButtons: function () {
|
||||
var oChecked = $('.selectList'+this.id+':checked', this.element);
|
||||
switch(oChecked.length)
|
||||
{
|
||||
switch (oChecked.length) {
|
||||
case 0:
|
||||
this.oButtons['delete'].prop('disabled', true);
|
||||
this.oButtons['remove'].prop('disabled', true);
|
||||
this.oButtons['modify'].prop('disabled', true);
|
||||
break;
|
||||
|
||||
break;
|
||||
|
||||
case 1:
|
||||
this.oButtons['delete'].prop('disabled', false);
|
||||
this.oButtons['remove'].prop('disabled', false);
|
||||
this.oButtons['modify'].prop('disabled', false);
|
||||
break;
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
this.oButtons['delete'].prop('disabled', false);
|
||||
this.oButtons['remove'].prop('disabled', false);
|
||||
this.oButtons['modify'].prop('disabled', true);
|
||||
break;
|
||||
break;
|
||||
}
|
||||
},
|
||||
_updateTable: function()
|
||||
{
|
||||
_updateTable: function () {
|
||||
var me = this;
|
||||
/*
|
||||
this.datatable.trigger("update").trigger("applyWidgets");
|
||||
this.datatable.tableHover();*/
|
||||
this.datatable.find('.selectList'+this.id).bind('change', function() { me._updateButtons(); });
|
||||
this.datatable.find('.selectList'+this.id).bind('change', function () {
|
||||
me._updateButtons();
|
||||
});
|
||||
|
||||
},
|
||||
_updateDlgPosition: function()
|
||||
{
|
||||
this.oDlg.dialog('option', { position: { my: "center", at: "center", of: window }});
|
||||
_updateDlgPosition: function () {
|
||||
this.oDlg.dialog('option', {position: {my: "center", at: "center", of: window}});
|
||||
},
|
||||
_createRow: function()
|
||||
{
|
||||
_createRow: function () {
|
||||
this.oButtons['create'].prop('disabled', true);
|
||||
this.indicator.html('<img src="../images/indicator.gif">');
|
||||
oParams = this.options.submit_parameters;
|
||||
@@ -176,30 +176,39 @@ $(function()
|
||||
oParams.att_code = this.options.att_code;
|
||||
oParams.iInputId = this.id;
|
||||
var me = this;
|
||||
if (this.options.oWizardHelper)
|
||||
{
|
||||
if (this.options.oWizardHelper) {
|
||||
this.options.oWizardHelper.UpdateWizard();
|
||||
oParams.json = this.options.oWizardHelper.ToJSON();
|
||||
}
|
||||
$.post(this.options.submit_to, oParams, function(data){
|
||||
$.post(this.options.submit_to, oParams, function (data) {
|
||||
me.oDlg = $('<div></div>');
|
||||
$('body').append(me.oDlg);
|
||||
me.oDlg.html(data);
|
||||
me.oDlg.find('form').removeAttr('onsubmit').bind('submit', function() { me._onCreateRow(); return false; } );
|
||||
me.oDlg.find('button.cancel').off('click').on('click', function() { me.oDlg.dialog('close'); } );
|
||||
|
||||
me.oDlg.find('form').removeAttr('onsubmit');
|
||||
me.oDlg.find('button[type="submit"]').on('click', function (event) {
|
||||
me._onCreateRow();
|
||||
return false;
|
||||
});
|
||||
setTimeout(function () {
|
||||
me.oDlg.find('button.cancel').off('click').on('click', function () {
|
||||
me.oDlg.dialog('close');
|
||||
});
|
||||
}, 500);
|
||||
me.oDlg.dialog({
|
||||
title: me.options.labels['creation_title'],
|
||||
modal: true,
|
||||
width: 'auto',
|
||||
height: 'auto',
|
||||
maxHeight: $(window).height() - 50,
|
||||
position: { my: "center", at: "center", of: window },
|
||||
close: function() { me._onDlgClose(); }
|
||||
maxHeight: $(window).height()-50,
|
||||
position: {my: "center", at: "center", of: window},
|
||||
close: function () {
|
||||
me._onDlgClose();
|
||||
}
|
||||
});
|
||||
me.indicator.html('');
|
||||
me.oButtons['create'].prop('disabled', false);
|
||||
me._updateDlgPosition();
|
||||
|
||||
});
|
||||
},
|
||||
_selectToAdd: function()
|
||||
@@ -221,38 +230,46 @@ $(function()
|
||||
}
|
||||
);
|
||||
|
||||
if (this.options.oWizardHelper)
|
||||
{
|
||||
if (this.options.oWizardHelper) {
|
||||
this.options.oWizardHelper.UpdateWizard();
|
||||
oParams.json = this.options.oWizardHelper.ToJSON();
|
||||
}
|
||||
var me = this;
|
||||
$.post(this.options.submit_to, oParams, function(data){
|
||||
$.post(this.options.submit_to, oParams, function (data) {
|
||||
me.oDlg = $('<div></div>');
|
||||
$('body').append(me.oDlg);
|
||||
me.oDlg.html(data);
|
||||
me.oDlg.find('form').removeAttr('onsubmit').bind('submit', function() { me._onSearchToAdd(); return false; } );
|
||||
$('#SearchFormToAdd_'+me.id).resize(function() { me._onSearchDlgUpdateSize(); });
|
||||
|
||||
me.oDlg.find('form').removeAttr('onsubmit').bind('submit', function () {
|
||||
me._onSearchToAdd();
|
||||
return false;
|
||||
});
|
||||
$('#SearchFormToAdd_'+me.id).resize(function () {
|
||||
me._onSearchDlgUpdateSize();
|
||||
});
|
||||
|
||||
me.oDlg.dialog({
|
||||
title: me.options.labels['selection_title'],
|
||||
modal: true,
|
||||
width: $(window).width()*0.8,
|
||||
height: $(window).height()*0.8,
|
||||
maxHeight: $(window).height() - 50,
|
||||
position: { my: "center", at: "center", of: window },
|
||||
close: function() { me._onDlgClose(); },
|
||||
resizeStop: function() { me._onSearchDlgUpdateSize(); },
|
||||
width: $(window).width() * 0.8,
|
||||
height: $(window).height() * 0.8,
|
||||
maxHeight: $(window).height()-50,
|
||||
position: {my: "center", at: "center", of: window},
|
||||
close: function () {
|
||||
me._onDlgClose();
|
||||
},
|
||||
resizeStop: function () {
|
||||
me._onSearchDlgUpdateSize();
|
||||
},
|
||||
buttons: [
|
||||
{
|
||||
text: Dict.S('UI:Button:Cancel'),
|
||||
class: "cancel ibo-is-alternative ibo-is-neutral",
|
||||
click: function() {
|
||||
click: function () {
|
||||
$(this).dialog('close');
|
||||
}
|
||||
},
|
||||
{
|
||||
text: Dict.S('UI:Button:Add'),
|
||||
text: Dict.S('UI:Button:Add'),
|
||||
class: "ok ibo-is-regular ibo-is-primary",
|
||||
click: function() {
|
||||
me._onDoAdd();
|
||||
@@ -439,39 +456,48 @@ $(function()
|
||||
var me = this;
|
||||
me.oDlg.find('button').prop('disabled', true);
|
||||
me.oDlg.find('span.indicator').html('<img src="../images/indicator.gif">');
|
||||
$.post(this.options.submit_to, oParams, function(data){
|
||||
$.post(this.options.submit_to, oParams, function (data) {
|
||||
me.oDlg.html(data);
|
||||
me.oDlg.find('form').removeAttr('onsubmit').bind('submit', function() { me._onCreateRow(); return false; } );
|
||||
me.oDlg.find('button.cancel').off('click').on('click', function() { me.oDlg.dialog('close'); } );
|
||||
me._updateDlgPosition();
|
||||
me.oDlg.find('form').removeAttr('onsubmit').bind('submit', function () {
|
||||
me._onCreateRow();
|
||||
return false;
|
||||
});
|
||||
me.oDlg.find('button.cancel').off('click').on('click', function () {
|
||||
me.oDlg.dialog('close');
|
||||
});
|
||||
me._updateDlgPosition();
|
||||
});
|
||||
},
|
||||
_onCreateRow: function()
|
||||
{
|
||||
_onCreateRow: function () {
|
||||
// Validate the form
|
||||
var me = this;
|
||||
var sFormId = this.oDlg.find('form').attr('id');
|
||||
if (CheckFields(sFormId, true))
|
||||
{
|
||||
if (CheckFields(sFormId, true)) {
|
||||
// Gather the values from the form
|
||||
me.oDlg.find('.htmlEditor').each(function () {
|
||||
CKEDITOR.instances[this.id].destroy();
|
||||
if ($('#'+this.id).data('timeout_validate') != undefined) {
|
||||
clearInterval($('#'+this.id).data('timeout_validate'));
|
||||
}
|
||||
});
|
||||
|
||||
oParams = this.options.submit_parameters;
|
||||
var oValues = {};
|
||||
this.oDlg.find(':input').each( function() {
|
||||
if (this.name != '')
|
||||
{
|
||||
this.oDlg.find(':input').each(function () {
|
||||
if (this.name != '') {
|
||||
oParams[this.name] = this.value;
|
||||
oValues[this.name] = this.value;
|
||||
}
|
||||
});
|
||||
var nextIdx = 0;
|
||||
for(k in this.toBeCreated)
|
||||
{
|
||||
for (k in this.toBeCreated) {
|
||||
nextIdx++;
|
||||
}
|
||||
nextIdx++;
|
||||
this.toBeCreated[nextIdx] = oValues;
|
||||
this.inputToBeCreated.val(JSON.stringify(this.toBeCreated));
|
||||
this.oDlg.dialog('close');
|
||||
|
||||
|
||||
oParams = this.options.submit_parameters;
|
||||
oParams.operation = 'getLinksetRow';
|
||||
oParams['class'] = this.options.class_name;
|
||||
@@ -483,7 +509,7 @@ $(function()
|
||||
this.oButtons['create'].prop('disabled', true);
|
||||
this.indicator.html('<img src="../images/indicator.gif">');
|
||||
|
||||
$.post(this.options.submit_to, oParams, function(data){
|
||||
$.post(this.options.submit_to, oParams, function (data) {
|
||||
// From data variable we get data entry and insert the first (and only) one
|
||||
me.datatable.DataTable().row.add(data.data[0]).draw();
|
||||
$('#datatable_'+me.id+' .dataTables_empty').hide();
|
||||
@@ -494,34 +520,27 @@ $(function()
|
||||
});
|
||||
}
|
||||
},
|
||||
_onDlgClose: function()
|
||||
{
|
||||
_onDlgClose: function () {
|
||||
this.oDlg.remove();
|
||||
this.oDlg = null;
|
||||
},
|
||||
_onSearchDlgUpdateSize: function()
|
||||
{
|
||||
_onSearchDlgUpdateSize: function () {
|
||||
var searchHeight = $('#SearchFormToAdd_'+this.id).outerHeight();
|
||||
var dlgHeight = this.oDlg.height();
|
||||
$('.wizContainer', this.oDlg).height(dlgHeight - 20);
|
||||
$('#SearchResultsToAdd_'+this.id).height(dlgHeight - 50 - searchHeight);
|
||||
$('.wizContainer', this.oDlg).height(dlgHeight-20);
|
||||
$('#SearchResultsToAdd_'+this.id).height(dlgHeight-50-searchHeight);
|
||||
},
|
||||
_deleteRow: function(oCheckbox)
|
||||
{
|
||||
_deleteRow: function (oCheckbox) {
|
||||
var iObjKey = parseInt(oCheckbox.val(), 10); // Number in base 10
|
||||
|
||||
if (iObjKey > 0)
|
||||
{
|
||||
|
||||
if (iObjKey > 0) {
|
||||
// Existing objet: add it to the "to be deleted" list
|
||||
// if it has not just been added now
|
||||
if (this._InArray(this.toBeAdded, iObjKey))
|
||||
{
|
||||
if (this._InArray(this.toBeAdded, iObjKey)) {
|
||||
this.toBeAdded = this._ArrayRemove(this.toBeAdded, iObjKey);
|
||||
this.inputToBeAdded.val(JSON.stringify(this.toBeAdded));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.toBeDeleted.push(iObjKey);
|
||||
this.inputToBeAdded.val(JSON.stringify(this.toBeAdded));
|
||||
} else {
|
||||
this.toBeDeleted.push(iObjKey);
|
||||
this.inputToBeDeleted.val(JSON.stringify(this.toBeDeleted));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user