mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-24 02:58:43 +02:00
N°6154 N°6219 - Relations Read - tooltip, confirmation title and message (#486)
N°6154 - n:n Read - tooltip, confirmation title and message on Add-Edit-Remove N°6219 - 1:n Read: tooltip, modal title and message on Add-Edit-Remove-Delete
This commit is contained in:
@@ -75,6 +75,10 @@ $(function()
|
||||
// retrieve table
|
||||
const $Table = $('table', this.element);
|
||||
|
||||
// retrieve new button
|
||||
const $NewButton = $('[name="UI:Links:New"]', this.element);
|
||||
const sButtonTooltipContent = $NewButton.attr('data-tooltip-content');
|
||||
|
||||
// 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');
|
||||
@@ -82,7 +86,7 @@ $(function()
|
||||
const sHostObjectId = $Table.closest('[data-role="ibo-object-details"]').attr('data-object-id');
|
||||
|
||||
// link object creation
|
||||
iTopLinkSetWorker.CreateLinkedObject(sClass, sAttCode, sHostObjectClass, sHostObjectId, function(){
|
||||
iTopLinkSetWorker.CreateLinkedObject(sButtonTooltipContent, sClass, sAttCode, sHostObjectClass, sHostObjectId, function(){
|
||||
$(this).find("form").remove();
|
||||
$(this).dialog('destroy');
|
||||
},function (event, data) {
|
||||
@@ -96,20 +100,29 @@ $(function()
|
||||
* ModifyLinkedObject.
|
||||
*
|
||||
* @param {string} sLinkedObjectKey
|
||||
* @param {Element} $TRElement
|
||||
* @param {string} sRemoteFriendlyname
|
||||
*/
|
||||
ModifyLinkedObject: function (sLinkedObjectKey) {
|
||||
ModifyLinkedObject: function (sLinkedObjectKey, $TRElement, sRemoteFriendlyname) {
|
||||
|
||||
const me = this;
|
||||
|
||||
|
||||
// retrieve modify button and extract modal title
|
||||
const $ModifyButton = $('[name="ModifyButton"]', $TRElement);
|
||||
const sButtonTooltipContent = $ModifyButton.attr('data-tooltip-content');
|
||||
let sButtonTitleContent = $ModifyButton.attr('data-modal-title');
|
||||
sButtonTitleContent = sButtonTitleContent.replaceAll('{item}', sRemoteFriendlyname);
|
||||
|
||||
// Specify that external key to host object will be readonly
|
||||
let aReadOnlyParams = {
|
||||
'readonly': {
|
||||
}
|
||||
}
|
||||
aReadOnlyParams['readonly'][this.options.external_key_to_me] = 1;
|
||||
|
||||
aReadOnlyParams['form_title'] = sButtonTitleContent;
|
||||
|
||||
// link object modification
|
||||
iTopObjectWorker.ModifyObject(this.options.link_class, sLinkedObjectKey, function () {
|
||||
iTopObjectWorker.ModifyObject(sButtonTooltipContent, this.options.link_class, sLinkedObjectKey, function () {
|
||||
$(this).find("form").remove();
|
||||
$(this).dialog('destroy');
|
||||
}, function(event, data){
|
||||
|
||||
@@ -46,6 +46,7 @@ const iTopLinkSetWorker = new function(){
|
||||
/**
|
||||
* CallAjaxCreateLinkedObject.
|
||||
*
|
||||
* @param {string} sModalTitle
|
||||
* @param {string} sClass
|
||||
* @param {string} sAttCode
|
||||
* @param {string} sHostObjectClass
|
||||
@@ -53,10 +54,10 @@ const iTopLinkSetWorker = new function(){
|
||||
* @param oOnModalCloseCallback
|
||||
* @param oOnFormSubmittedCallback
|
||||
*/
|
||||
const CallAjaxCreateLinkedObject = function(sClass, sAttCode, sHostObjectClass, sHostObjectId, oOnModalCloseCallback = null, oOnFormSubmittedCallback = null){
|
||||
const CallAjaxCreateLinkedObject = function(sModalTitle, sClass, sAttCode, sHostObjectClass, sHostObjectId, oOnModalCloseCallback = null, oOnFormSubmittedCallback = null){
|
||||
|
||||
let oOptions = {
|
||||
title: Dict.S('UI:Links:New:Modal:Title'),
|
||||
title: sModalTitle,
|
||||
content: {
|
||||
endpoint: `${ROUTER_BASE_URL}?route=${ROUTE_LINK_SET_CREATE_OBJECT}`,
|
||||
data: {
|
||||
|
||||
@@ -15,7 +15,7 @@ const iTopLinkSet = new function () {
|
||||
const CallCreateLinkedObject = function(sLinkedClass, oWidget)
|
||||
{
|
||||
// Create link object
|
||||
iTopObjectWorker.CreateObject(sLinkedClass, function(){
|
||||
iTopObjectWorker.CreateObject(Dict.S('UI:Links:Object:New:Modal:Title'), sLinkedClass, function(){
|
||||
$(this).find("form").remove();
|
||||
$(this).dialog('destroy');
|
||||
},
|
||||
|
||||
@@ -5,17 +5,18 @@ const iTopObjectWorker = new function(){
|
||||
const ROUTE_CREATE_OBJECT = 'object.new';
|
||||
const ROUTE_MODIFY_OBJECT = 'object.modify';
|
||||
const ROUTE_GET_OBJECT = 'object.get';
|
||||
|
||||
|
||||
/**
|
||||
* CallAjaxCreateObject.
|
||||
*
|
||||
* @param {string} sTitle
|
||||
* @param {string} sClass
|
||||
* @param oOnModalCloseCallback
|
||||
* @param oOnFormSubmittedCallback
|
||||
* @param {Object} aAdditionalData
|
||||
* @constructor
|
||||
*/
|
||||
const CallAjaxCreateObject = function(sClass, oOnModalCloseCallback = null, oOnFormSubmittedCallback = null, aAdditionalData = []){
|
||||
const CallAjaxCreateObject = function(sTitle, sClass, oOnModalCloseCallback = null, oOnFormSubmittedCallback = null, aAdditionalData = []){
|
||||
let aData = $.extend(
|
||||
{
|
||||
class: sClass,
|
||||
@@ -24,7 +25,7 @@ const iTopObjectWorker = new function(){
|
||||
);
|
||||
|
||||
let oOptions = {
|
||||
title: Dict.S('UI:Object:Modal:Title'),
|
||||
title: sTitle,
|
||||
content: {
|
||||
endpoint: `${ROUTER_BASE_URL}?route=${ROUTE_CREATE_OBJECT}`,
|
||||
data: aData
|
||||
@@ -43,6 +44,7 @@ const iTopObjectWorker = new function(){
|
||||
/**
|
||||
* CallAjaxModifyObject.
|
||||
*
|
||||
* @param {string} sTitle
|
||||
* @param {string} sObjectClass
|
||||
* @param {string} sObjectKey
|
||||
* @param oOnModalCloseCallback
|
||||
@@ -50,7 +52,7 @@ const iTopObjectWorker = new function(){
|
||||
* @param {Object} aAdditionalData
|
||||
* @constructor
|
||||
*/
|
||||
const CallAjaxModifyObject = function(sObjectClass, sObjectKey, oOnModalCloseCallback, oOnFormSubmittedCallback, aAdditionalData = []){
|
||||
const CallAjaxModifyObject = function(sTitle, sObjectClass, sObjectKey, oOnModalCloseCallback, oOnFormSubmittedCallback, aAdditionalData = []){
|
||||
let aData = $.extend(
|
||||
{
|
||||
class: sObjectClass,
|
||||
@@ -58,9 +60,9 @@ const iTopObjectWorker = new function(){
|
||||
},
|
||||
aAdditionalData
|
||||
);
|
||||
|
||||
|
||||
let oOptions = {
|
||||
title: Dict.S('UI:Links:ActionRow:Modify:Modal:Title'),
|
||||
title: sTitle,
|
||||
content: {
|
||||
endpoint: `${ROUTER_BASE_URL}?route=${ROUTE_MODIFY_OBJECT}`,
|
||||
data: aData,
|
||||
@@ -93,7 +95,7 @@ const iTopObjectWorker = new function(){
|
||||
},
|
||||
aAdditionalData
|
||||
)
|
||||
|
||||
|
||||
$.post(`${ROUTER_BASE_URL}?route=${ROUTE_GET_OBJECT}`, aData, oOnResponseCallback);
|
||||
};
|
||||
|
||||
|
||||
@@ -325,10 +325,12 @@ CombodoModal._ConvertButtonDefinition = function (aButtonsDefinitions) {
|
||||
if(aButtonsDefinitions === null) {
|
||||
return aConverted
|
||||
}
|
||||
aButtonsDefinitions.forEach(element => {
|
||||
Object.keys(aButtonsDefinitions).forEach(key => {
|
||||
const element = aButtonsDefinitions[key];
|
||||
console.log(element);
|
||||
const aButton = {
|
||||
text: element.text,
|
||||
class: element.class,
|
||||
class: typeof(element.classes) !== 'undefined' ? element.classes.join(' ') : '',
|
||||
click: element.callback_on_click
|
||||
}
|
||||
aConverted.push(aButton);
|
||||
@@ -366,43 +368,40 @@ CombodoModal.OpenConfirmationModal = function(oOptions, aData) {
|
||||
}
|
||||
}
|
||||
// Merge external options with confirmation modal default options
|
||||
oOptions = $.extend({
|
||||
oOptions = $.extend(true, {
|
||||
title: Dict.S('UI:Modal:DefaultConfirmationTitle'),
|
||||
content: '',
|
||||
confirm_button_label: null,
|
||||
do_not_show_again_pref_key: null,
|
||||
callback_on_confirm: null,
|
||||
callback_on_cancel: null,
|
||||
extra_options: {
|
||||
callback_on_modal_close: function () {
|
||||
$(this).dialog( "destroy" ); // destroy dialog object
|
||||
}
|
||||
},
|
||||
buttons: [
|
||||
{
|
||||
buttons: {
|
||||
cancel: {
|
||||
text: Dict.S('UI:Button:Cancel'),
|
||||
class: 'ibo-is-alternative',
|
||||
classes: ['ibo-is-alternative'],
|
||||
callback_on_click: function () {
|
||||
// call confirm handler and close dialog
|
||||
let bCanClose = true;
|
||||
if(oOptions.callback_on_cancel != null){
|
||||
if (oOptions.callback_on_cancel != null) {
|
||||
bCanClose = oOptions.callback_on_cancel(...aData) !== false;
|
||||
}
|
||||
if(bCanClose){
|
||||
if (bCanClose) {
|
||||
$(this).dialog('close'); // close dialog
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
text: oOptions.confirm_button_label ?? Dict.S('UI:Button:Confirm'),
|
||||
class: 'ibo-is-primary',
|
||||
confirm: {
|
||||
text: Dict.S('UI:Button:Confirm'),
|
||||
classes: ['ibo-is-primary'],
|
||||
callback_on_click: function () {
|
||||
// Call confirm handler and close dialog
|
||||
let bCanClose = true;
|
||||
if(oOptions.callback_on_confirm != null){
|
||||
if (oOptions.callback_on_confirm != null) {
|
||||
bCanClose = oOptions.callback_on_confirm(...aData) !== false;
|
||||
}
|
||||
if(bCanClose){
|
||||
if (bCanClose) {
|
||||
$(this).dialog('close'); // close dialog
|
||||
// Handle "do not show again" user preference
|
||||
let bDoNotShowAgain = oOptions.do_not_show_again_pref_key !== null ?
|
||||
@@ -414,7 +413,7 @@ CombodoModal.OpenConfirmationModal = function(oOptions, aData) {
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
},
|
||||
callback_on_content_loaded: function(oModalContentElement){
|
||||
// Add option do not show again from template
|
||||
if(oOptions.do_not_show_again_pref_key !== null) {
|
||||
@@ -444,15 +443,15 @@ CombodoModal.OpenInformativeModal = function(sMessage, sSeverity, oOptions) {
|
||||
$(this).dialog( "destroy" );
|
||||
}
|
||||
},
|
||||
buttons: [
|
||||
{
|
||||
buttons: {
|
||||
ok: {
|
||||
text: Dict.S('UI:Button:Ok'),
|
||||
class: 'ibo-is-regular ibo-is-neutral',
|
||||
// classes: ['ibo-is-regular', 'ibo-is-neutral'],
|
||||
callback_on_click: function () {
|
||||
$(this).dialog('close');
|
||||
$(this).dialog('close');
|
||||
}
|
||||
},
|
||||
],
|
||||
},
|
||||
}, oOptions);
|
||||
|
||||
// Open modal
|
||||
|
||||
Reference in New Issue
Block a user