Files
iTop/js/links/links_view_table_widget.js
bdalsass 1fe9520b7e N°5904 - Use attribute linked set edit mode to enable actions (#440)
* Add corresponding buttons depending on old edit mode (need to check with piR pour récuperer l'ancienne valeur.

* N°5904 - Handle attribute linked set edit_mode

* N°5904 Move calls to private jquery widget methods to public

* N°5904 - Worker improvements add button on link tagset

* Change itop set widget to new set block UI (5)

* Change itop set widget to new set block UI (5)

* Renommage variables JS avec le prefix combodo

* Search dialog block id conflict with form id

* add moved js files in iTopWebPage compatibility list

---------

Co-authored-by: Stephen Abello <stephen.abello@combodo.com>
2023-02-06 16:07:55 +01:00

116 lines
2.8 KiB
JavaScript

$(function()
{
// the widget definition, where "itop" is the namespace,
// "links_view_table" the widget name
$.widget( "itop.links_view_table",
{
// default options
options:
{
link_class: null,
external_key_to_me: null
},
// the constructor
_create: function () {
$Table = $('table', this.element);
this.$tableSettingsDialog = $('#datatable_dlg_' + $Table.attr('id'));
},
// the destructor
_destroy: function () {
},
/**
* DeleteLinkedObject.
*
* @param sLinkedObjectKey
* @param oTrElement
* @constructor
*/
DeleteLinkedObject: function (sLinkedObjectKey, oTrElement) {
const me = this;
// link object deletion
CombodoLinkSetWorker.DeleteLinkedObject(this.options.link_class, sLinkedObjectKey, function (data) {
if (data.data.success === true) {
oTrElement.remove();
} else {
CombodoModal.OpenInformativeModal(data.data.error_message, 'error');
}
});
},
/**
* DetachLinkedObject.
*
* @param sLinkedObjectKey
* @param oTrElement
* @constructor
*/
DetachLinkedObject: function (sLinkedObjectKey, oTrElement) {
const me = this;
// link object unlink
CombodoLinkSetWorker.DetachLinkedObject(this.options.link_class, sLinkedObjectKey, this.options.external_key_to_me, function (data) {
if (data.data.success === true) {
oTrElement.remove();
} else {
CombodoModal.OpenInformativeModal(data.data.error_message, 'error');
}
});
},
/**
* CreateLinkedObject.
*
*/
CreateLinkedObject: function () {
const me = this;
// retrieve table
const $Table = $('table', this.element);
// retrieve context parameters
const sClass = $Table.closest('[data-role="ibo-block-links-table"]').attr('data-link-class');
const sAttCode = $Table.closest('[data-role="ibo-block-links-table"]').attr('data-link-attcode');
const sHostObjectClass = $Table.closest('[data-role="ibo-object-details"]').attr('data-object-class');
const sHostObjectId = $Table.closest('[data-role="ibo-object-details"]').attr('data-object-id');
// link object creation
CombodoLinkSetWorker.CreateLinkedObject(sClass, sAttCode, sHostObjectClass, sHostObjectId, function(){
$(this).find("form").remove();
$(this).dialog('destroy');
},function (event, data) {
if(data.success){
me.$tableSettingsDialog.DataTableSettings('DoRefresh');
}
});
},
/**
* ModifyLinkedObject.
*
* @param {string} sLinkedObjectKey
*/
ModifyLinkedObject: function (sLinkedObjectKey) {
const me = this;
// link object modification
ObjectWorker.ModifyObject(this.options.link_class, sLinkedObjectKey, function () {
$(this).find("form").remove();
$(this).dialog('destroy');
}, function(event, data){
if(data.success) {
me.$tableSettingsDialog.DataTableSettings('DoRefresh');
}
});
},
});
});