Add implementation for credential_type lookup

This commit is contained in:
gconsidine 2017-06-26 10:52:14 -04:00
parent 2fa4b3db5b
commit d63ab2811a
6 changed files with 33 additions and 40 deletions

View File

@ -25,20 +25,15 @@ function AddCredentialsController (models, $state) {
vm.form.organization._resource = 'organization';
vm.form.organization._route = 'credentials.add.organization';
vm.form.credential_type._resource = 'credentialType';
vm.form.credential_type._resource = 'credential_type';
vm.form.credential_type._route = 'credentials.add.credentialType';
/*
* vm.form.credential_type._data = credentialType.get('results');
* vm.form.credential_type._placeholder = 'SELECT A TYPE';
* vm.form.credential_type._format = 'grouped-object';
* vm.form.credential_type._display = 'name';
* vm.form.credential_type._key = 'id';
* vm.form.credential_type._exp = 'type as type.name group by type.kind for type in state._data';
*
*/
vm.form.inputs = {
_get: credentialType.mergeInputProperties,
_get: id => {
let type = credentialType.getById(id);
return credentialType.mergeInputProperties(type);
},
_source: vm.form.credential_type,
_reference: 'vm.form.inputs',
_key: 'inputs'

View File

@ -1,9 +1,4 @@
<at-panel ng-if="$state.current.name === 'credentials.add' ||
$state.current.name === 'credentials.edit' ||
$state.current.name === 'credentials.add.organization' ||
$state.current.name === 'credentials.edit.organization' ||
$state.current.name === 'credentials.add.credentialType' ||
$state.current.name === 'credentials.edit.credentialType'">
<at-panel ng-if="!$state.current.name.includes('permissions')">
<at-panel-heading>{{ vm.panelTitle }}</at-panel-heading>
<at-tab-group>
@ -26,15 +21,14 @@
</at-input-group>
<at-action-group col="12" pos="right">
<at-form-action type="cancel"></at-form-action>
<at-form-action type="cancel" to="credentials"></at-form-action>
<at-form-action type="save"></at-form-action>
</at-action-group>
</at-form>
</at-panel-body>
</at-panel>
<at-panel ng-if="$state.current.name === 'credentials.edit.permissions' ||
$state.current.name === 'credentials.edit.permissions.add'">
<at-panel ng-if="$state.current.name.includes('permissions')">
<at-panel-heading>CREDENTIALS PERMISSIONS</at-panel-heading>
<at-tab-group>
@ -47,5 +41,5 @@
</at-panel-body>
</at-panel>
<div ng-if="$state.current.name === 'credentials.edit.permissions.add'" ui-view="modal"></div>
<div ng-if="$state.current.name.includes('permissions.add')" ui-view="modal"></div>

View File

@ -6,6 +6,7 @@ function EditCredentialsController (models, $state, $scope) {
let me = models.me;
let credential = models.credential;
let credentialType = models.credentialType;
let selectedCredentialType = credentialType.getById(credential.get('credential_type'));
vm.tab = {
details: {
@ -43,15 +44,14 @@ function EditCredentialsController (models, $state, $scope) {
vm.form.organization._value = credential.get('summary_fields.organization.id');
vm.form.organization._displayValue = credential.get('summary_fields.organization.name');
vm.form.credential_type._data = credentialType.get('results');
vm.form.credential_type._format = 'grouped-object';
vm.form.credential_type._display = 'name';
vm.form.credential_type._key = 'id';
vm.form.credential_type._exp = 'type as type.name group by type.kind for type in state._data';
vm.form.credential_type._value = credentialType.getById(credential.get('credential_type'));
vm.form.credential_type._resource = 'credential_type';
vm.form.credential_type._route = 'credentials.edit.credentialType';
vm.form.credential_type._value = selectedCredentialType.id;
vm.form.credential_type._displayValue = selectedCredentialType.name;
vm.form.inputs = {
_get (type) {
_get (id) {
let type = credentialType.getById(id);
let inputs = credentialType.mergeInputProperties(type);
if (type.id === credential.get('credential_type')) {

View File

@ -321,14 +321,14 @@ function LegacyCredentialsService (pathService) {
return this.organization;
case 'add-credential-type':
this.credentialType.name = 'credentials.add.credentialType';
this.credentialType.views['credentialType@credentials.add'] = {
this.credentialType.views['credential_type@credentials.add'] = {
templateProvider: this.lookupTemplateProvider
};
return this.credentialType;
case 'edit-credential-type':
this.credentialType.name = 'credentials.edit.credentialType';
this.credentialType.views['credentialType@credentials.edit'] = {
this.credentialType.views['credential_type@credentials.edit'] = {
templateProvider: this.lookupTemplateProvider
};

View File

@ -39,7 +39,7 @@ function atFormActionController ($state) {
scope.text = 'CANCEL';
scope.fill = 'Hollow';
scope.color = 'default';
scope.action = () => $state.go('^');
scope.action = () => $state.go(scope.to || '^');
};
vm.setSaveDefaults = () => {
@ -64,7 +64,8 @@ function atFormAction (pathService) {
link,
scope: {
state: '=',
type: '@'
type: '@',
to: '@'
}
};
}

View File

@ -19,16 +19,20 @@ function AtInputLookupController (baseInputController, $state, $stateParams) {
scope = _scope_;
scope.$watch(scope.state._resource, () => {
if (scope[scope.state._resource]) {
scope.state._value = scope[scope.state._resource];
scope.state._displayValue = scope[`${scope.state._resource}_name`];
}
});
scope.$watch(scope.state._resource, vm.watchResource);
vm.check();
};
vm.watchResource = () => {
if (scope[scope.state._resource]) {
scope.state._value = scope[scope.state._resource];
scope.state._displayValue = scope[`${scope.state._resource}_name`];
vm.check();
}
};
vm.search = () => {
let params = {};
@ -36,7 +40,6 @@ function AtInputLookupController (baseInputController, $state, $stateParams) {
params.selected = scope.state._value;
}
console.log(scope.state);
$state.go(scope.state._route, params);
};
}