|
@@ -52,7 +52,7 @@
|
|
|
var drilldownActionIndex;
|
|
|
var levelPrimaryAction;
|
|
|
var url = '';
|
|
|
- console.log(data, row);
|
|
|
+
|
|
|
// Preparing actions on the cell
|
|
|
levelActions = oLevelsProperties[data.level_alias].actions;
|
|
|
// - Removing explicit (not default) drilldown action as it has no prupose on that browse mode
|
|
@@ -108,48 +108,76 @@
|
|
|
// - Secondary actions
|
|
|
if(levelActionsKeys.length > 1)
|
|
|
{
|
|
|
- var actionsElem = $('<div></div>').addClass('pull-right group-actions');
|
|
|
- cellElem.append(actionsElem);
|
|
|
-
|
|
|
- // Preparing secondary actions for small screens
|
|
|
- var actionsSSTogglerElem = $('<a class="glyphicon glyphicon-menu-hamburger" data-toggle="collapse" data-target="#item-actions-menu-'+levelAltId+'"></a>');
|
|
|
- var actionsSSMenuElem = $('<div id="item-actions-menu-'+levelAltId+'" class="item-action-wrapper panel panel-default"></div>');
|
|
|
- var actionsSSMenuContainerElem = $('<div class="panel-body"></div>');
|
|
|
- actionsSSMenuElem.append(actionsSSMenuContainerElem);
|
|
|
- actionsElem.append(actionsSSTogglerElem);
|
|
|
- actionsElem.append(actionsSSMenuElem);
|
|
|
-
|
|
|
+ // Retrieving secondary action
|
|
|
var actionsButtons = {};
|
|
|
- // Fill actionsButtons with all actions but the primary
|
|
|
for(j = 1; j < levelActionsKeys.length; j++)
|
|
|
{
|
|
|
actionsButtons[levelActionsKeys[j]] = levelActions[levelActionsKeys[j]];
|
|
|
}
|
|
|
+
|
|
|
+ // Preparing secondary actions container
|
|
|
+ var actionsElem = $('<div></div>').addClass('pull-right group-actions');
|
|
|
+ cellElem.append(actionsElem);
|
|
|
+ // Checking if a menu is necessary
|
|
|
+ var bHasSeveralSecondaryActions = (Object.keys(actionsButtons).length > 1);
|
|
|
+ // Preparing secondary actions for small screens
|
|
|
+ if(bHasSeveralSecondaryActions)
|
|
|
+ {
|
|
|
+ var actionsSSTogglerElem = $('<a class="glyphicon glyphicon-menu-hamburger" data-toggle="collapse" data-target="#item-actions-menu-'+levelAltId+'"></a>');
|
|
|
+ var actionsSSMenuElem = $('<div id="item-actions-menu-'+levelAltId+'" class="item-action-wrapper panel panel-default"></div>');
|
|
|
+ var actionsSSMenuContainerElem = $('<div class="panel-body"></div>');
|
|
|
+ actionsSSMenuElem.append(actionsSSMenuContainerElem);
|
|
|
+ actionsElem.append(actionsSSTogglerElem);
|
|
|
+ actionsElem.append(actionsSSMenuElem);
|
|
|
+ }
|
|
|
+
|
|
|
+ // Adding secondary actions
|
|
|
for(j in actionsButtons)
|
|
|
{
|
|
|
var action = actionsButtons[j];
|
|
|
var actionElem = $('<a></a>');
|
|
|
+ var actionIconElem = $('<span></span>').appendTo(actionElem);
|
|
|
|
|
|
switch(action.type)
|
|
|
{
|
|
|
case '{{ constant('Combodo\\iTop\\Portal\\Brick\\BrowseBrick::ENUM_ACTION_VIEW') }}':
|
|
|
url = '{{ app.url_generator.generate('p_object_view', {'sObjectClass': '-objectClass-', 'sObjectId': '-objectId-'})|raw }}'.replace(/-objectClass-/, data.class).replace(/-objectId-/, data.id);
|
|
|
- actionElem.attr('data-toggle', 'modal').attr('data-target', '#modal-for-all').attr('href', url).text(action.title);
|
|
|
+ actionElem.attr('data-toggle', 'modal').attr('data-target', '#modal-for-all').attr('href', url);
|
|
|
break;
|
|
|
case '{{ constant('Combodo\\iTop\\Portal\\Brick\\BrowseBrick::ENUM_ACTION_EDIT') }}':
|
|
|
url = '{{ app.url_generator.generate('p_object_edit', {'sObjectClass': '-objectClass-', 'sObjectId': '-objectId-'})|raw }}'.replace(/-objectClass-/, data.class).replace(/-objectId-/, data.id);
|
|
|
- actionElem.attr('data-toggle', 'modal').attr('data-target', '#modal-for-all').attr('href', url).text(action.title);
|
|
|
+ actionElem.attr('data-toggle', 'modal').attr('data-target', '#modal-for-all').attr('href', url);
|
|
|
break;
|
|
|
case '{{ constant('Combodo\\iTop\\Portal\\Brick\\BrowseBrick::ENUM_ACTION_CREATE_FROM_THIS') }}':
|
|
|
url = action.url.replace(/-objectClass-/, data.class).replace(/-objectId-/, data.id);
|
|
|
url = addParameterToUrl(url, 'ar_token', data.action_rules_token[action.type]);
|
|
|
- actionElem.attr('data-toggle', 'modal').attr('data-target', '#modal-for-all').attr('href', url).text(action.title);
|
|
|
+ actionElem.attr('data-toggle', 'modal').attr('data-target', '#modal-for-all').attr('href', url);
|
|
|
break;
|
|
|
default:
|
|
|
console.log('Action "'+action.type+'" not implemented for secondary action');
|
|
|
break;
|
|
|
}
|
|
|
- actionsSSMenuContainerElem.append( $('<p></p>').append(actionElem.clone()) );
|
|
|
+
|
|
|
+ // Adding title if present
|
|
|
+ if(action.title !== undefined)
|
|
|
+ {
|
|
|
+ actionElem.attr('title', action.title);
|
|
|
+ }
|
|
|
+ // Adding icon class if present
|
|
|
+ if(action.icon_class !== undefined)
|
|
|
+ {
|
|
|
+ actionIconElem.addClass(action.icon_class);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(bHasSeveralSecondaryActions)
|
|
|
+ {
|
|
|
+ actionElem.append(action.title);
|
|
|
+ actionsSSMenuContainerElem.append( $('<p></p>').append(actionElem) );
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ actionsElem.append(actionElem);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|