1
0
mirror of https://github.com/ansible/awx.git synced 2024-11-01 16:51:11 +03:00

Merge pull request #4090 from mabashian/workflows-permissions-notifications

Notifications/Permissions with WFJT's
This commit is contained in:
Michael Abashian 2016-11-22 10:14:17 -05:00 committed by GitHub
commit a1a581f961
8 changed files with 47 additions and 19 deletions

View File

@ -28,6 +28,7 @@ export default
activeEditState: 'templates.editJobTemplate', activeEditState: 'templates.editJobTemplate',
// (optional) array of supporting templates to ng-include inside generated html // (optional) array of supporting templates to ng-include inside generated html
include: ['/static/partials/survey-maker-modal.html'], include: ['/static/partials/survey-maker-modal.html'],
detailsClick: "$state.go('templates.editJobTemplate')",
fields: { fields: {
name: { name: {
@ -420,6 +421,7 @@ export default
iterator: 'permission', iterator: 'permission',
index: false, index: false,
open: false, open: false,
ngClick: "$state.go('templates.editJobTemplate.permissions')",
actions: { actions: {
add: { add: {
ngClick: "$state.go('.add')", ngClick: "$state.go('.add')",
@ -482,11 +484,13 @@ export default
for (itm in JobTemplateFormObject.related) { for (itm in JobTemplateFormObject.related) {
if (JobTemplateFormObject.related[itm].include === "NotificationsList") { if (JobTemplateFormObject.related[itm].include === "NotificationsList") {
JobTemplateFormObject.related[itm] = NotificationsList; JobTemplateFormObject.related[itm] = _.clone(NotificationsList);
JobTemplateFormObject.related[itm].ngClick = "$state.go('templates.editJobTemplate.notifications')";
JobTemplateFormObject.related[itm].generateList = true; // tell form generator to call list generator and inject a list JobTemplateFormObject.related[itm].generateList = true; // tell form generator to call list generator and inject a list
} }
if (JobTemplateFormObject.related[itm].include === "CompletedJobsList") { if (JobTemplateFormObject.related[itm].include === "CompletedJobsList") {
JobTemplateFormObject.related[itm] = CompletedJobsList; JobTemplateFormObject.related[itm] = CompletedJobsList;
JobTemplateFormObject.related[itm].ngClick = "$state.go('templates.editJobTemplate.completed_jobs')";
JobTemplateFormObject.related[itm].generateList = true; JobTemplateFormObject.related[itm].generateList = true;
} }
} }

View File

@ -25,6 +25,7 @@ export default
stateTree: 'templates', stateTree: 'templates',
activeEditState: 'templates.editWorkflowJobTemplate', activeEditState: 'templates.editWorkflowJobTemplate',
tabs: true, tabs: true,
detailsClick: "$state.go('templates.editWorkflowJobTemplate')",
fields: { fields: {
name: { name: {
@ -114,6 +115,7 @@ export default
iterator: 'permission', iterator: 'permission',
index: false, index: false,
open: false, open: false,
ngClick: "$state.go('templates.editWorkflowJobTemplate.permissions')",
actions: { actions: {
add: { add: {
ngClick: "$state.go('.add')", ngClick: "$state.go('.add')",
@ -198,7 +200,8 @@ export default
for (itm in WorkflowFormObject.related) { for (itm in WorkflowFormObject.related) {
if (WorkflowFormObject.related[itm].include === "NotificationsList") { if (WorkflowFormObject.related[itm].include === "NotificationsList") {
WorkflowFormObject.related[itm] = NotificationsList; WorkflowFormObject.related[itm] = _.clone(NotificationsList);
WorkflowFormObject.related[itm].ngClick = "$state.go('templates.editWorkflowJobTemplate.notifications')";
WorkflowFormObject.related[itm].generateList = true; // tell form generator to call list generator and inject a list WorkflowFormObject.related[itm].generateList = true; // tell form generator to call list generator and inject a list
} }
} }

View File

@ -22,7 +22,7 @@ export default ['Wait', 'GetBasePath', 'ProcessErrors', 'Rest',
notifier_id = params.notifier.id, notifier_id = params.notifier.id,
callback = params.callback, callback = params.callback,
column = params.column, // notification_template_success/notification_template__error column = params.column, // notification_template_success/notification_template__error
url = params.url + "/"+ column + '/'; url = params.url + "/" + column + '/';
if(!notifier[column]){ if(!notifier[column]){
params = { params = {

View File

@ -1149,7 +1149,7 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat
html += "<input "; html += "<input ";
html += (field.spinner) ? "" : "type=\"text\" "; html += (field.spinner) ? "" : "type=\"text\" ";
html += "\" value=\"" + field['default'] + "\" "; html += " value=\"" + field['default'] + "\" ";
html += "class=\""; html += "class=\"";
if (!field.slider && !field.spinner) { if (!field.slider && !field.spinner) {
html += "form-control"; html += "form-control";
@ -1494,22 +1494,22 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat
html += "<div class=\"Form-tabHolder\">"; html += "<div class=\"Form-tabHolder\">";
if(this.mode === "edit"){ if(this.mode === "edit"){
html += `<div id="${this.form.name}_tab" class="Form-tab" ` + html += `<div id="${this.form.name}_tab" class="Form-tab" `;
`ng-click="$state.go('${this.form.stateTree}.edit')" ` + html += this.form.detailsClick ? `ng-click="` + this.form.detailsClick + `" ` : `ng-click="$state.go('${this.form.stateTree}.edit')" `;
`ng-class="{'is-selected': $state.is('${this.form.activeEditState}') || $state.is('${this.form.stateTree}.edit') || $state.$current.data.formChildState }">` + html += `ng-class="{'is-selected': $state.is('${this.form.activeEditState}') || $state.is('${this.form.stateTree}.edit') || $state.$current.data.formChildState }">` +
`${details}</div>`; `${details}</div>`;
for (itm in this.form.related) { for (itm in this.form.related) {
collection = this.form.related[itm]; collection = this.form.related[itm];
html += `<div id="${itm}_tab" `+ html += `<div id="${itm}_tab" `+
`class="Form-tab" `+ `class="Form-tab" `;
`ng-click="$state.go('${this.form.stateTree}.edit.${itm}')" `; html += (this.form.related[itm].ngClick) ? `ng-click="` + this.form.related[itm].ngClick + `" ` : `ng-click="$state.go('${this.form.stateTree}.edit.${itm}')" `;
if (collection.awToolTip){ if (collection.awToolTip){
html += `aw-tool-tip="${collection.awToolTip}" ` + html += `aw-tool-tip="${collection.awToolTip}" ` +
`aw-tip-placement="${collection.dataPlacement}" ` + `aw-tip-placement="${collection.dataPlacement}" ` +
`data-tip-watch="${collection.dataTipWatch}" `; `data-tip-watch="${collection.dataTipWatch}" `;
} }
html += `ng-class="{'is-selected' : $state.is('${this.form.activeEditState}.${itm}') || $state.is('${this.form.stateTree}.edit.${itm}')}" ` ; html += `ng-class="{'is-selected' : $state.is('${this.form.activeEditState}.${itm}') || $state.is('${this.form.stateTree}.edit.${itm}') ` ;
if(this.form.related[itm].disabled){ if(this.form.related[itm].disabled){
html += `, 'Form-tab--disabled' : ${this.form.related[itm].disabled }`; html += `, 'Form-tab--disabled' : ${this.form.related[itm].disabled }`;
} }
@ -1594,7 +1594,7 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat
html += "</div>";//tabHolder html += "</div>";//tabHolder
} }
if(!_.isEmpty(this.form.related) && this.mode === "edit"){// TODO: either include $state.is('templates.editWorkflowJobTemplate') or figure out something else to do here if(!_.isEmpty(this.form.related) && this.mode === "edit"){
html += `<div class="Form-tabSection" ng-class="{'is-selected' : $state.is('${this.form.activeEditState}') || $state.is('${this.form.stateTree}.edit') || $state.$current.data.formChildState }">`; html += `<div class="Form-tabSection" ng-class="{'is-selected' : $state.is('${this.form.activeEditState}') || $state.is('${this.form.stateTree}.edit') || $state.$current.data.formChildState }">`;
} }
@ -1648,7 +1648,7 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat
} }
else if (!field.subForm && currentSubForm !== undefined) { else if (!field.subForm && currentSubForm !== undefined) {
currentSubForm = undefined; currentSubForm = undefined;
html += '</div></div> '; html += '</div> ';
} }
html += this.buildField(fld, field, options, this.form); html += this.buildField(fld, field, options, this.form);
@ -1773,12 +1773,17 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat
} }
} }
if(!_.isEmpty(this.form.related) && this.mode === "edit"){
html += `</div>`;
}
if (this.form.include){ if (this.form.include){
_.forEach(this.form.include, (template) =>{ _.forEach(this.form.include, (template) =>{
html += `<div ng-include="'${template}'"></div>`; html += `<div ng-include="'${template}'"></div>`;
}); });
} }
// console.log(html) // console.log(html);
return this.wrapPanel(html, options.noPanel); return this.wrapPanel(html, options.noPanel);
}, },

View File

@ -166,8 +166,7 @@ export default
} }
ToggleNotification({ ToggleNotification({
scope: $scope, scope: $scope,
url: defaultUrl, url: defaultUrl + id,
id: id,
notifier: notifier, notifier: notifier,
column: column, column: column,
callback: 'NotificationRefresh' callback: 'NotificationRefresh'

View File

@ -38,7 +38,7 @@ export default
isDisabled: '=ngDisabled', isDisabled: '=ngDisabled',
preview: '=' preview: '='
}, },
templateUrl: templateUrl('job-templates/survey-maker/render/multiple-choice'), templateUrl: templateUrl('templates/survey-maker/render/multiple-choice'),
link: _.partial(link, $timeout, CreateSelect2) link: _.partial(link, $timeout, CreateSelect2)
}; };
return directive; return directive;

View File

@ -119,7 +119,7 @@ export default
isDisabled: '@ngDisabled', isDisabled: '@ngDisabled',
preview: '=' preview: '='
}, },
templateUrl: templateUrl('job-templates/survey-maker/render/survey-question'), templateUrl: templateUrl('templates/survey-maker/render/survey-question'),
link: _.partial(link, $sce, $filter, Empty) link: _.partial(link, $sce, $filter, Empty)
}; };

View File

@ -8,12 +8,12 @@
[ '$scope', '$stateParams', 'WorkflowForm', 'GenerateForm', 'Alert', 'ProcessErrors', [ '$scope', '$stateParams', 'WorkflowForm', 'GenerateForm', 'Alert', 'ProcessErrors',
'ClearScope', 'GetBasePath', '$q', 'ParseTypeChange', 'Wait', 'Empty', 'ClearScope', 'GetBasePath', '$q', 'ParseTypeChange', 'Wait', 'Empty',
'ToJSON', 'initSurvey', '$state', 'CreateSelect2', 'ParseVariableString', 'ToJSON', 'initSurvey', '$state', 'CreateSelect2', 'ParseVariableString',
'TemplatesService', 'OrganizationList', 'Rest', 'WorkflowService', 'TemplatesService', 'OrganizationList', 'Rest', 'WorkflowService', 'ToggleNotification',
function( function(
$scope, $stateParams, WorkflowForm, GenerateForm, Alert, ProcessErrors, $scope, $stateParams, WorkflowForm, GenerateForm, Alert, ProcessErrors,
ClearScope, GetBasePath, $q, ParseTypeChange, Wait, Empty, ClearScope, GetBasePath, $q, ParseTypeChange, Wait, Empty,
ToJSON, SurveyControllerInit, $state, CreateSelect2, ParseVariableString, ToJSON, SurveyControllerInit, $state, CreateSelect2, ParseVariableString,
TemplatesService, OrganizationList, Rest, WorkflowService TemplatesService, OrganizationList, Rest, WorkflowService, ToggleNotification
) { ) {
ClearScope(); ClearScope();
@ -616,6 +616,23 @@
$state.transitionTo('templates'); $state.transitionTo('templates');
}; };
$scope.toggleNotification = function(event, notifier_id, column) {
var notifier = this.notification;
try {
$(event.target).tooltip('hide');
}
catch(e) {
// ignore
}
ToggleNotification({
scope: $scope,
url: GetBasePath('workflow_job_templates') + id,
notifier: notifier,
column: column,
callback: 'NotificationRefresh'
});
};
init(); init();
} }
]; ];