Various fixes to the templates list based on audit feedback

This commit is contained in:
Michael Abashian 2016-12-12 14:02:59 -05:00
parent 824fb21b3f
commit deca2bb5c1
6 changed files with 36 additions and 13 deletions

View File

@ -47,6 +47,7 @@ export default
label: i18n._('Labels'),
type: 'labels',
nosort: true,
showDelete: true,
columnClass: 'List-tableCell col-lg-2 col-md-4 hidden-sm hidden-xs'
}
},
@ -58,7 +59,7 @@ export default
basePaths: ['templates'],
awToolTip: i18n._('Create a new template'),
actionClass: 'btn List-dropdownSuccess',
buttonContent: i18n._('ADD'),
buttonContent: '+ ' + i18n._('ADD'),
options: [
{
optionContent: i18n._('Job Template'),
@ -109,7 +110,8 @@ export default
awToolTip: i18n._('Edit template'),
"class": 'btn-default btn-xs',
dataPlacement: 'top',
ngShow: 'template.summary_fields.user_capabilities.edit'
ngShow: 'template.summary_fields.user_capabilities.edit',
editStateParams: ['job_template_id', 'workflow_job_template_id']
},
view: {
label: i18n._('View'),

View File

@ -29,9 +29,9 @@
</span>
</div>
<span ng-if="!options.showTipWhenDisabled">
<div class="btn-group" ng-if="options.type === 'buttonDropdown'" ng-disabled="{{options.ngDisabled}}" aw-tool-tip="{{options.awToolTip}}" data-tip-watch="{{options.dataTipWatch}}" data-placement="{{options.dataPlacement}}" data-container="{{options.dataContainer}}">
<div class="btn-group" ng-if="options.type === 'buttonDropdown'" ng-disabled="{{options.ngDisabled}}" aw-tool-tip="{{options.awToolTip}}" data-tip-watch="{{options.dataTipWatch}}" data-placement="{{options.dataPlacement}}" data-container="{{options.dataContainer}}" ng-show="{{options.ngShow}}">
<button type="button" class="{{options.actionClass}} List-dropdownButton dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span>{{options.buttonContent}}&nbsp;</span>
<span ng-bind-html="options.buttonContent"></span>
<span class="List-dropdownCarat"></span>
<span class="sr-only">Toggle Dropdown</span>
</button>

View File

@ -355,6 +355,16 @@ export default ['$location', '$compile', '$rootScope', 'Attr', 'Icon',
innerTable += "<td class=\"List-actionsContainer\"><div class=\"List-actionButtonCell List-tableCell\">";
let handleEditStateParams = function(stateParams){console.log(stateParams);
let matchingConditions = [];
angular.forEach(stateParams, function(stateParam) {
matchingConditions.push(`$stateParams['` + stateParam + `'] == ${list.iterator}.id`);
});
return matchingConditions;
};
for (field_action in list.fieldActions) {
if (field_action !== 'columnClass') {
if (list.fieldActions[field_action].type && list.fieldActions[field_action].type === 'DropDown') {
@ -376,8 +386,19 @@ export default ['$location', '$compile', '$rootScope', 'Attr', 'Icon',
innerTable += "class=\"List-actionButton ";
innerTable += (field_action === 'delete' || field_action === 'cancel') ? "List-actionButton--delete" : "";
innerTable += "\" ";
// rowBeingEdited === '{{ " + list.iterator + ".id }}' && listBeingEdited === '" + list.name + "' ? 'List-tableRow--selected' : ''";
innerTable += (field_action === 'edit') ? `ng-class="{'List-editButton--selected' : $stateParams['${list.iterator}_id'] == ${list.iterator}.id}"`: '';
if(field_action === 'edit') {
// editStateParams allows us to handle cases where a list might have different types of resources in it. As a result the edit
// icon might now always point to the same state and differing states may have differing stateParams. Specifically this occurs
// on the Templates list where editing a workflow job template takes you to a state where the param is workflow_job_template_id.
// You can also edit a Job Template from this list so the stateParam there would be job_template_id.
if(list.fieldActions[field_action].editStateParams) {
let matchingConditions = handleEditStateParams(list.fieldActions[field_action].editStateParams);
innerTable += `ng-class="{'List-editButton--selected' : ${matchingConditions.join(' || ')}}"`;
}
else {
innerTable += `ng-class="{'List-editButton--selected' : $stateParams['${list.iterator}_id'] == ${list.iterator}.id}"`;
}
}
innerTable += (fAction.awPopOver) ? "aw-pop-over=\"" + fAction.awPopOver + "\" " : "";
innerTable += (fAction.dataPlacement) ? Attr(fAction, 'dataPlacement') : "";
innerTable += (fAction.dataTitle) ? Attr(fAction, 'dataTitle') : "";

View File

@ -8,7 +8,8 @@ export default
'Prompt',
'$q',
'$filter',
function(templateUrl, Wait, Rest, GetBasePath, ProcessErrors, Prompt, $q, $filter) {
'$state',
function(templateUrl, Wait, Rest, GetBasePath, ProcessErrors, Prompt, $q, $filter, $state) {
return {
restrict: 'E',
scope: false,
@ -63,9 +64,8 @@ export default
Rest.setUrl(url);
Rest.post({"disassociate": true, "id": labelId})
.success(function () {
// @issue: OLD SEARCH
// scope.search("job_template", scope.$parent.job_template_page);
Wait('stop');
$state.go('.', null, {reload: true});
})
.error(function (data, status) {
Wait('stop');

View File

@ -1,10 +1,10 @@
<div class="LabelList-tagContainer" ng-repeat="label in labels">
<div class="LabelList-deleteContainer"
ng-click="deleteLabel(job_template.id, job_template.name, label.id, label.name)"
ng-show="showDelete && job_template.summary_fields.can_edit">
ng-click="deleteLabel(template.id, template.name, label.id, label.name)"
ng-show="showDelete && template.summary_fields.user_capabilities.edit">
<i class="fa fa-times LabelList-tagDelete"></i>
</div>
<div class="LabelList-tag" ng-class="{'LabelList-tag--deletable' : (showDelete && job_template.summary_fields.can_edit)}">
<div class="LabelList-tag" ng-class="{'LabelList-tag--deletable' : (showDelete && template.summary_fields.user_capabilities.edit)}">
<span class="LabelList-name">{{ label.name }}</span>
</div>
</div>

View File

@ -107,7 +107,7 @@ export default ['$scope', '$rootScope', '$location', '$stateParams', 'Rest', 'Al
if(template) {
Prompt({
hdr: 'Delete',
body: '<div class="Prompt-bodyQuery">Are you sure you want to delete the ' + (template.type === "Workflow Job Template" ? 'workflow ' : '') + 'job template below?</div><div class="Prompt-bodyTarget">' + $filter('sanitize')(template.name) + '</div>',
body: '<div class="Prompt-bodyQuery">Are you sure you want to delete the template below?</div><div class="Prompt-bodyTarget">' + $filter('sanitize')(template.name) + '</div>',
action: function() {
function handleSuccessfulDelete() {