WIP working base case: inventory lookup state

This commit is contained in:
Leigh Johnson
2016-11-03 18:07:41 -04:00
parent 50f0465094
commit ed5fb05c17
5 changed files with 84 additions and 53 deletions

View File

@@ -50,7 +50,7 @@ export default
sourceField: 'name', sourceField: 'name',
list: 'OrganizationList', list: 'OrganizationList',
basePath: 'organization', basePath: 'organization',
//ngClick: 'lookUpInventory()', ngClick: 'lookUpInventory()',
requiredErrorMsg: "Please select an Inventory.", requiredErrorMsg: "Please select an Inventory.",
column: 1, column: 1,
class: 'Form-formGroup--fullWidth', class: 'Form-formGroup--fullWidth',

View File

@@ -136,11 +136,11 @@ angular.module('jobTemplates', [surveyMaker.name, jobTemplatesList.name, jobTemp
} }
}, },
views: { views: {
'modal@templates.editWorkflowJobTemplate.workflowMaker': { 'related': {
templateProvider: function(ListDefinition, generateList) { templateProvider: function(InventoryList, generateList) {
let list_html = generateList.build({ let list_html = generateList.build({
mode: 'lookup', mode: 'lookup',
list: ListDefinition, list: InventoryList,
input_type: 'radio' input_type: 'radio'
}); });
return `<lookup-modal>${list_html}</lookup-modal>`; return `<lookup-modal>${list_html}</lookup-modal>`;
@@ -149,10 +149,9 @@ angular.module('jobTemplates', [surveyMaker.name, jobTemplatesList.name, jobTemp
} }
}, },
resolve: { resolve: {
// ListDefinition: [InventoryList, function(list) { ListDefinition: ['InventoryList', function(list) {
// list.iterator = field.sourceModel; return list;
// return list; }],
// }],
Dataset: ['InventoryList', 'QuerySet', '$stateParams', 'GetBasePath', Dataset: ['InventoryList', 'QuerySet', '$stateParams', 'GetBasePath',
(list, qs, $stateParams, GetBasePath) => { (list, qs, $stateParams, GetBasePath) => {
let path = GetBasePath(list.name) || GetBasePath(list.basePath); let path = GetBasePath(list.name) || GetBasePath(list.basePath);
@@ -184,7 +183,7 @@ angular.module('jobTemplates', [surveyMaker.name, jobTemplatesList.name, jobTemp
}, [ }, [
stateExtender.buildDefinition(jobTemplatesListRoute), stateExtender.buildDefinition(jobTemplatesListRoute),
workflowMaker, workflowMaker,
//inventoryLookup inventoryLookup
]) ])
}; };
}); });

View File

@@ -3,44 +3,44 @@ export default ['CreateDialog', 'Wait', '$q', function(CreateDialog, Wait, $q){
openDialog: function(params){ openDialog: function(params){
// params.scope // params.scope
let deferred = $q.defer(); // let deferred = $q.defer();
if (params.scope.removeWorkflowDialogReady) { // if (params.scope.removeWorkflowDialogReady) {
params.scope.removeWorkflowDialogReady(); // params.scope.removeWorkflowDialogReady();
} // }
params.scope.removeWorkflowDialogReady = params.scope.$on('WorkflowDialogReady', function() { // params.scope.removeWorkflowDialogReady = params.scope.$on('WorkflowDialogReady', function() {
$('#workflow-modal-dialog').dialog('open'); // $('#workflow-modal-dialog').dialog('open');
deferred.resolve(); // deferred.resolve();
}); // });
Wait('start'); // Wait('start');
debugger; // debugger;
CreateDialog({ // CreateDialog({
id: 'workflow-modal-dialog', // id: 'workflow-modal-dialog',
scope: params.scope, // scope: params.scope,
width: 1400, // width: 1400,
height: 720, // height: 720,
draggable: false, // draggable: false,
dialogClass: 'SurveyMaker-dialog', // dialogClass: 'SurveyMaker-dialog',
position: ['center',20], // position: ['center',20],
onClose: function() { // onClose: function() {
$('#workflow-modal-dialog').empty(); // $('#workflow-modal-dialog').empty();
}, // },
onOpen: function() { // onOpen: function() {
Wait('stop'); // Wait('stop');
// Let the modal height be variable based on the content // // Let the modal height be variable based on the content
// and set a uniform padding // // and set a uniform padding
$('#workflow-modal-dialog').css({'padding': '20px'}); // $('#workflow-modal-dialog').css({'padding': '20px'});
}, // },
_allowInteraction: function(e) { // _allowInteraction: function(e) {
return !!$(e.target).is('.select2-input') || this._super(e); // return !!$(e.target).is('.select2-input') || this._super(e);
}, // },
callback: 'WorkflowDialogReady' // callback: 'WorkflowDialogReady'
}); // });
return deferred.promise; // return deferred.promise;
}, },
closeDialog: function() { closeDialog: function() {
$('#workflow-modal-dialog').dialog('destroy'); $('#workflow-modal-dialog').dialog('destroy');

View File

@@ -5,11 +5,11 @@
*************************************************/ *************************************************/
export default ['$scope', 'WorkflowHelpService', 'generateList', 'JobTemplateList', 'ProjectList', export default ['$scope', 'WorkflowHelpService', 'generateList', 'JobTemplateList', 'ProjectList',
'GetBasePath', 'Wait', 'JobTemplateService', 'GetBasePath', 'Wait', 'JobTemplateService', '$state',
'ProcessErrors', 'InventorySourcesList', 'CreateSelect2', 'WorkflowMakerForm', 'ProcessErrors', 'InventorySourcesList', 'CreateSelect2', 'WorkflowMakerForm',
'GenerateForm', 'InventoryList', 'CredentialList', '$q', '$timeout', 'GenerateForm', 'InventoryList', 'CredentialList', '$q', '$timeout',
function($scope, WorkflowHelpService, GenerateList, JobTemplateList, ProjectList, function($scope, WorkflowHelpService, GenerateList, JobTemplateList, ProjectList,
GetBasePath, Wait, JobTemplateService, GetBasePath, Wait, JobTemplateService, $state,
ProcessErrors, InventorySourcesList, CreateSelect2, WorkflowMakerForm, ProcessErrors, InventorySourcesList, CreateSelect2, WorkflowMakerForm,
GenerateForm, InventoryList, CredentialList, $q, $timeout) { GenerateForm, InventoryList, CredentialList, $q, $timeout) {
@@ -64,14 +64,8 @@ export default ['$scope', 'WorkflowHelpService', 'generateList', 'JobTemplateLis
function init() { function init() {
$scope.treeDataMaster = angular.copy($scope.treeData.data); $scope.treeDataMaster = angular.copy($scope.treeData.data);
WorkflowHelpService.openDialog({ $scope.$broadcast("refreshWorkflowChart");
scope: $scope
})
.then(function() {
//$scope.$broadcast("refreshWorkflowChart");
});
$scope.$watchCollection('workflow_job_templates', function() { $scope.$watchCollection('workflow_job_templates', function() {
if ($scope.selectedTemplate) { if ($scope.selectedTemplate) {
// Loop across the inventories and see if one of them should be "checked" // Loop across the inventories and see if one of them should be "checked"
@@ -149,6 +143,12 @@ export default ['$scope', 'WorkflowHelpService', 'generateList', 'JobTemplateLis
} }
$scope.lookUpInventory = function(){
console.log($state)
$state.go('.inventory')
};
$scope.closeWorkflowMaker = function() { $scope.closeWorkflowMaker = function() {
// Revert the data to the master which was created when the dialog was opened // Revert the data to the master which was created when the dialog was opened
$scope.treeData.data = angular.copy($scope.treeDataMaster); $scope.treeData.data = angular.copy($scope.treeDataMaster);

View File

@@ -6,8 +6,8 @@
import workflowMakerController from './workflow-maker.controller'; import workflowMakerController from './workflow-maker.controller';
export default [ 'templateUrl', export default ['templateUrl', 'CreateDialog', 'Wait',
function(templateUrl) { function(templateUrl, CreateDialog, Wait) {
return { return {
scope: { scope: {
treeData: '=' treeData: '='
@@ -15,6 +15,38 @@ export default [ 'templateUrl',
restrict: 'E', restrict: 'E',
templateUrl: templateUrl('job-templates/workflow-maker/workflow-maker'), templateUrl: templateUrl('job-templates/workflow-maker/workflow-maker'),
controller: workflowMakerController, controller: workflowMakerController,
link: function(scope) {
CreateDialog({
id: 'workflow-modal-dialog',
scope: scope,
width: 1400,
height: 720,
draggable: false,
dialogClass: 'SurveyMaker-dialog',
position: ['center', 20],
onClose: function() {
$('#workflow-modal-dialog').empty();
},
onOpen: function() {
Wait('stop');
// Let the modal height be variable based on the content
// and set a uniform padding
$('#workflow-modal-dialog').css({ 'padding': '20px' });
},
_allowInteraction: function(e) {
return !!$(e.target).is('.select2-input') || this._super(e);
},
callback: 'WorkflowDialogReady'
});
if (scope.removeWorkflowDialogReady) {
scope.removeWorkflowDialogReady();
}
scope.removeWorkflowDialogReady = scope.$on('WorkflowDialogReady', function() {
$('#workflow-modal-dialog').dialog('open');
});
}
}; };
} }
]; ];