Add message for a result of update metadata
At the moment, even when a user update a metadata, this result is not informed to a user (any message is not displayed). So a user cannot know its result and he has to redisplay 'Update Metadata' modal in order to know its result. Change-Id: I02b1a3c70d0225d2326d038b7519d49b0082985e Closes-Bug: #1608361
This commit is contained in:
parent
ccc6de3430
commit
d8df8bf78b
@ -23,8 +23,9 @@
|
||||
|
||||
MetadataModalController.$inject = [
|
||||
'$modalInstance',
|
||||
'horizon.framework.widgets.metadata.tree.service',
|
||||
'horizon.app.core.metadata.service',
|
||||
'horizon.framework.widgets.metadata.tree.service',
|
||||
'horizon.framework.widgets.toast.service',
|
||||
// Dependencies injected with resolve by $modal.open
|
||||
'available',
|
||||
'existing',
|
||||
@ -38,8 +39,8 @@
|
||||
* Controller used by `ModalService`
|
||||
*/
|
||||
function MetadataModalController(
|
||||
$modalInstance, metadataTreeService, metadataService,
|
||||
available, existing, params
|
||||
$modalInstance, metadataService, metadataTreeService,
|
||||
toastService, available, existing, params
|
||||
) {
|
||||
var ctrl = this;
|
||||
|
||||
@ -80,10 +81,12 @@
|
||||
}
|
||||
|
||||
function onEditSuccess() {
|
||||
toastService.add('success', gettext('Metadata was successfully updated.'));
|
||||
$modalInstance.close();
|
||||
}
|
||||
|
||||
function onEditFailure() {
|
||||
toastService.add('error', gettext('Unable to update metadata.'));
|
||||
ctrl.saving = false;
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@
|
||||
'use strict';
|
||||
|
||||
describe('MetadataModalController', function () {
|
||||
var $controller, treeService, modalInstance;
|
||||
var $controller, treeService, modalInstance, toast;
|
||||
|
||||
var metadataService = {
|
||||
editMetadata: function() {}
|
||||
@ -53,10 +53,12 @@
|
||||
});
|
||||
|
||||
beforeEach(module('horizon.app.core.metadata.modal',
|
||||
'horizon.framework.widgets.metadata.tree'));
|
||||
'horizon.framework'));
|
||||
beforeEach(inject(function (_$controller_, $injector) {
|
||||
$controller = _$controller_;
|
||||
treeService = $injector.get('horizon.framework.widgets.metadata.tree.service');
|
||||
toast = $injector.get('horizon.framework.widgets.toast.service');
|
||||
spyOn(toast, 'add');
|
||||
}));
|
||||
|
||||
it('should dismiss modal on cancel', function () {
|
||||
@ -84,6 +86,7 @@
|
||||
expect(modalInstance.close).toHaveBeenCalled();
|
||||
expect(metadataService.editMetadata)
|
||||
.toHaveBeenCalledWith('aggregate', '123', {'custom': 'bar'}, ['UPPER_lower']);
|
||||
expect(toast.add).toHaveBeenCalledWith('success', 'Metadata was successfully updated.');
|
||||
});
|
||||
|
||||
it('should clear saving flag on failed save', function() {
|
||||
@ -103,6 +106,7 @@
|
||||
expect(modalInstance.close).not.toHaveBeenCalled();
|
||||
expect(metadataService.editMetadata)
|
||||
.toHaveBeenCalledWith('aggregate', '123', {'custom': 'bar'}, ['UPPER_lower']);
|
||||
expect(toast.add).toHaveBeenCalledWith('error', 'Unable to update metadata.');
|
||||
});
|
||||
|
||||
function createController() {
|
||||
|
Loading…
Reference in New Issue
Block a user