Skip to content

Commit

Permalink
Merge pull request #506 from AudiovisualMetadataPlatform/AMP-3131_ref…
Browse files Browse the repository at this point in the history
…actor

Amp 3131 refactor
  • Loading branch information
yingfeng-iu authored Apr 16, 2024
2 parents a54b9ea + 53c1903 commit 39647bf
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 7 deletions.
7 changes: 5 additions & 2 deletions src/components/entity/EntityList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1329,8 +1329,7 @@ export default {
const self = this;
try {
self.showLoader = true;
const configPropertiesResponse = await self.configPropertiesService.getConfigProperties();
self.configProperties = configPropertiesResponse.data;
self.configProperties = await self.configPropertiesService.getConfigProperties();
self.showLoader = false;
} catch (error) {
self.showLoader = false;
Expand All @@ -1344,6 +1343,10 @@ export default {
self.assignedRolesUnitChanged = true;
self.settingsRolesUnitChanged = true;
} else if (self.baseUrl === "collection") {
// if current collection exists but fields not populated, get its details
if (self.selectedCollection && self.selectedCollection.id && !self.selectedCollection.name) {
self.selectedCollection = await this.collectionService.getCollectionDetails(self.selectedCollection.id);
}
self.entity = self.selectedCollection;
if (self.selectedCollection && !self.isCreatePage)
this.getCollectionItems();
Expand Down
4 changes: 2 additions & 2 deletions src/components/supplement/SupplementFile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,6 @@ export default {
},
data() {
return {
loading: false,
superLoading: false,
unitService: new UnitService(),
itemService: new ItemService(),
sharedService: new SharedService(),
Expand All @@ -306,6 +304,8 @@ export default {
supplementService: new SupplementService(),
accessControlService: new AccessControlService(),
configPropertiesService: new ConfigPropertiesService(),
loading: false,
superLoading: false,
supplement: {
showCollectionList: false,
collectionList: [],
Expand Down
7 changes: 7 additions & 0 deletions src/service/collection-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,20 @@
import { result } from 'underscore';
import BaseService from './base-service.js';
const baseService = new BaseService();

export default class CollectionService extends BaseService{
// Get collection detail
async getCollectionDetails(id) {
return super.get_auth(`/collections/${id}`).then(result => result.data);
}

async getCollectionPage(num,size){
if(num && size){
return super.get_auth(`/collections?page=${num}&size=${size}`)
}
else return super.get_auth('/collections');
}

async activateCollection(id, active){
return await super.patch_auth(`/collections/${id}`,
{
Expand Down
2 changes: 1 addition & 1 deletion src/service/config-properties-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default class ConfigPropertiesService extends BaseService {
* @method GET
*/

async getConfigProperties() {
getConfigProperties() {
return super.get_auth(`/config`).then(result => result.data);
}
}
2 changes: 1 addition & 1 deletion src/service/entity-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default class EntityService {
await unitService.getUnitById(defaultUnit).then(res => {
unitDetails.response = res;
}).catch(err => {
self.$bvToast.toast("Unable to retrive unit details. Please try again!", context.sharedService.erorrToastConfig);
self.$bvToast.toast("Unable to retrieve unit details. Please try again!", context.sharedService.erorrToastConfig);
});
return unitDetails;
}
Expand Down
2 changes: 1 addition & 1 deletion src/service/unit-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const baseService = new BaseService();
export default class UnitService extends BaseService{

/***
* To get all unit details
* To get the list of all units.
* @params num, size
*/

Expand Down

0 comments on commit 39647bf

Please sign in to comment.