Add method to remove input data on credential type change

This commit is contained in:
gconsidine 2017-06-09 11:02:01 -04:00
parent 09ac71518e
commit 2b01c24dce
5 changed files with 55 additions and 3 deletions

View File

@ -35,6 +35,7 @@ function EditCredentialsController (models, $state) {
vm.form.save = data => {
data.user = me.getSelf().id;
credential.clearTypeInputs();
return credential.request('put', data);
};

View File

@ -0,0 +1,44 @@
function atInputCheckboxLink (scope, element, attrs, controllers) {
let formController = controllers[0];
let inputController = controllers[1];
if (scope.tab === '1') {
element.find('input')[0].focus();
}
inputController.init(scope, element, formController);
}
function AtInputCheckboxController (baseInputController) {
let vm = this || {};
vm.init = (scope, element, form) => {
baseInputController.call(vm, 'input', scope, element, form);
vm.check();
};
}
AtInputCheckboxController.$inject = ['BaseInputController'];
function atInputCheckbox (pathService) {
return {
restrict: 'E',
transclude: true,
replace: true,
require: ['^^atForm', 'atInputCheckbox'],
templateUrl: pathService.getPartialPath('components/input/checkbox'),
controller: AtInputCheckboxController,
controllerAs: 'vm',
link: atInputCheckboxLink,
scope: {
state: '=',
col: '@',
tab: '@'
}
};
}
atInputCheckbox.$inject = ['PathService'];
export default atInputCheckbox;

View File

@ -37,9 +37,11 @@ function AtInputTextareaSecretController (baseInputController, eventService) {
scope.buttonText = 'REPLACE';
} else {
scope.state._hint = scope.state._hint || DEFAULT_HINT;
vm.listeners = vm.setFileListeners(textarea, input);
}
if (scope.state.format === 'ssh_private_key') {
vm.listeners = vm.setFileListeners(textarea, input);
}
}
vm.updateModel();
};

View File

@ -33,11 +33,16 @@ function assignInputGroupValues (inputs) {
});
}
function clearTypeInputs () {
delete this.model.GET.inputs;
}
function CredentialModel (method, resource) {
BaseModel.call(this, 'credentials');
this.createFormSchema = createFormSchema.bind(this);
this.assignInputGroupValues = assignInputGroupValues.bind(this);
this.clearTypeInputs = clearTypeInputs.bind(this);
return this.request(method, resource)
.then(() => this);