Skip to content

Commit

Permalink
Merge pull request #530 from AudiovisualMetadataPlatform/AMP-2532_tas…
Browse files Browse the repository at this point in the history
…kManager

AMP-2532:
  • Loading branch information
yingfeng-iu authored Aug 7, 2024
2 parents 03a1a07 + 88e3da2 commit 4a43d2d
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 28 deletions.
20 changes: 10 additions & 10 deletions src/components/entity/EntityList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@
<div class="row">
<div
class="text-left form-group"
:class="baseUrl === 'collection' ? 'col-6' : 'col-12'"
:class="baseUrl === 'unit' ? 'col-6' : 'col-12'"
>
<label>
<span class="text-capitalize">{{ baseUrl }}</span> Name:
Expand Down Expand Up @@ -211,16 +211,16 @@
</div>
<div
class="col-6 text-left form-group"
v-if="baseUrl === 'collection'"
v-if="baseUrl === 'unit'"
>
<label>Task Manager:</label>
<select
class="select custom-select w-100"
v-model="entity.taskManager"
:disabled="
showEdit ||
(baseUrl === 'collection' &&
!accessControl._collection._update)
(baseUrl === 'unit' &&
!accessControl._unit._update)
"
:class="{
'error-border': submitted && !entity.taskManager,
Expand Down Expand Up @@ -968,7 +968,7 @@ export default {
selectedCollection: sync("selectedCollection"),
selectedItem: sync("selectedItem"),
selectedFile: sync("selectedFile"),
itemConfigs: sync("itemConfigs"),
entityConfigs: sync("entityConfigs"),
configProperties: sync("configProperties"),
baseUrl() {
const self = this;
Expand All @@ -980,7 +980,7 @@ export default {
window.location.hash.toLowerCase().indexOf("collection") > -1 &&
window.location.hash.toLowerCase().indexOf("item") === -1
) {
this.getItemsConfig();
this.getEntityConfigs();
return "collection";
} else if (window.location.hash.toLowerCase().indexOf("item") > -1) {
return "item";
Expand All @@ -999,10 +999,10 @@ export default {
);
},
listOfTaskManager() {
return this.itemConfigs.taskManagers;
return this.entityConfigs.taskManagers;
},
listOfExternalResources() {
return this.itemConfigs.externalSources;
return this.entityConfigs.externalSources;
},
mediaInfo() {
return this.selectedFile && this.selectedFile.mediaInfo
Expand Down Expand Up @@ -1453,9 +1453,9 @@ export default {
onInputChange(ev) {
this.isDataChanged = true;
},
async getItemsConfig() {
async getEntityConfigs() {
const self = this;
self.entityService.getItemsConfig(self);
self.entityService.getEntityConfigs(self);
},
handleSearchItem() {
this.$router.push("/collections/items/item-search");
Expand Down
26 changes: 14 additions & 12 deletions src/service/entity-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ export default class EntityService {

async onUpdateEntityDetails(self) {
if (self.baseUrl === 'unit') {
// unit Validation rules
if (!self.entity.name || !self.entity.taskManager) {
self.$bvToast.toast("Please provide required fields!", self.sharedService.erorrToastConfig);
return false;
}
self.unitService.updateUnitDetails(self.selectedUnit.id, self.entity).then(response => {
self.isDataChanged = false;
self.$bvToast.toast("Unit details updated successfully.", self.sharedService.successToastConfig);
Expand All @@ -29,11 +34,9 @@ export default class EntityService {
self.submitted = true;

// Collection Validation rules
if (!self.entity.name || !self.entity.taskManager) {

if (!self.entity.name) {
self.$bvToast.toast("Please provide required fields!", self.sharedService.erorrToastConfig);
return false;

}
if (!self.isCreatePage) {
self.collectionService.updateCollection(self.entity).then(response => {
Expand Down Expand Up @@ -72,7 +75,8 @@ export default class EntityService {
}
} else if (self.baseUrl === 'file') {
self.submitted = true;
// Collection Validation rules

// file Validation rules
if (!self.entity.name) {
self.$bvToast.toast("Please provide required fields!", self.sharedService.erorrToastConfig);
return false;
Expand All @@ -98,7 +102,7 @@ export default class EntityService {
} else if (self.baseUrl === 'item') {
self.submitted = true;

// Collection Validation rules
// item Validation rules
if (!self.entity.name) {
self.$bvToast.toast("Please provide required fields!", self.sharedService.erorrToastConfig);
return false;
Expand All @@ -117,7 +121,6 @@ export default class EntityService {
self.selectedItem.selectedItemId = response.id;
self.isDataChanged = false;
self.$router.push("/collections/items/details");
// self.$router.push("/collection/details");
}).catch(error => {
self.showLoader = false;
self.submitted = false;
Expand All @@ -133,7 +136,6 @@ export default class EntityService {
self.itemService.updateItem(self.entity).then(success => {
self.showLoader = false;
self.$bvToast.toast("Item details updated successfully", { title: 'Notification', appendToast: true, variant: "success", autoHideDelay: 5000 });
// self.showEdit = !self.showEdit;
self.submitted = false;
self.isDataChanged = false;
}).catch(error => {
Expand All @@ -151,11 +153,11 @@ export default class EntityService {
}
}

async getItemsConfig(self) {
if(!self.itemConfigs.externalSources.length || !self.itemConfigs.taskManagers.length) {
await self.itemService.getItemsConfig().then(res => {
self.itemConfigs.externalSources = res.externalSources;
self.itemConfigs.taskManagers = res.taskManagers;
async getEntityConfigs(self) {
if(!self.entityConfigs.externalSources.length || !self.entityConfigs.taskManagers.length) {
await self.itemService.getEntityConfigs().then(res => {
self.entityConfigs.externalSources = res.externalSources;
self.entityConfigs.taskManagers = res.taskManagers;
}).catch(err => {
self.$bvToast.toast("Unable to retrive config details. Please try again!", self.sharedService.erorrToastConfig);
})
Expand Down
2 changes: 1 addition & 1 deletion src/service/item-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export default class ItemService extends BaseService{
* @params obj, id
*/

async getItemsConfig(){
async getEntityConfigs(){
var data = "";
await super.get_auth(`/config?properties=externalSources,taskManagers`).then(result => data = result.data);
return data;
Expand Down
2 changes: 1 addition & 1 deletion src/store/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ const state = {
isAuthenticated: false,
selectedFile: {},
selectedFilters: {},
itemConfigs: {
entityConfigs: {
externalSources: [],
taskManagers: [],
},
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/components/entity/EntityList.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ jest.mock('../../../../src/service/primary-file-service',
return jest.fn().mockImplementation(
function () {
const superFn = {
getItemsConfig: (id) => {
getEntityConfigs: (id) => {
return Promise.resolve({"externalSources":["MCO","DarkAvalon"],"taskManagers":["Jira","Trello"]})
}
};
Expand Down Expand Up @@ -112,7 +112,7 @@ describe('EntityList.vue', () => {
selectedUnit: {},
selectedFile: {},
selectedFilters: {},
itemConfigs: {
entityConfigs: {
externalSources: [],
taskManagers: []
},
Expand Down Expand Up @@ -168,7 +168,7 @@ describe('EntityList.vue', () => {
});

it('should fetch config values', async () => {
await wrapper.vm.getItemsConfig();
expect(wrapper.vm.itemConfigs.externalSources.length).toBe(2)
await wrapper.vm.getEntityConfigs();
expect(wrapper.vm.entityConfigs.externalSources.length).toBe(2)
});
});

0 comments on commit 4a43d2d

Please sign in to comment.