Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AMP-3131 #505

Merged
merged 1 commit into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions src/components/entity/EntityList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1331,7 +1331,6 @@ export default {
self.showLoader = true;
const configPropertiesResponse = await self.configPropertiesService.getConfigProperties();
self.configProperties = configPropertiesResponse.data;

self.showLoader = false;
} catch (error) {
self.showLoader = false;
Expand All @@ -1350,12 +1349,10 @@ export default {
this.getCollectionItems();
else {
self.selectedCollection = self.entity = {};
self.showLoader = false;
self.showEdit = false;
}
} else if (self.baseUrl === "item") {
self.entity = self.selectedItem;
self.showLoader = false;
if (self.isCreatePage) {
self.selectedItem = self.entity = {};
self.showEdit = false;
Expand Down Expand Up @@ -1487,38 +1484,38 @@ export default {
},
mounted() {
const self = this;
self.showLoader = true;
if (!self.configProperties) {

// retrieve configProperties if not yet populated
if (!self.configProperties || Object.keys(self.configProperties).length === 0) {
self.getConfigs();
}

// For unit details page
// retrieve units list and currentUnit info from storage if available, otherwise initialize them
const uEntity = JSON.parse(sessionStorage.getItem("unitEntity"));

if (!uEntity) {
self.unitEntity = { unitList: [], currentUnit: "" };
}
else {
self.unitEntity = uEntity;
}

// retrieve units list if not yet populated
if (!self.unitEntity.unitList || !self.unitEntity.unitList.length) {
self.getAllUnits();
}

// if currentUnit set, gegetEntityData for the page
if (self.unitEntity.currentUnit) {
self.getEntityData();
}

// adjust size of PFile fields for PFile page
let formHTML = document.getElementsByClassName("form")[0];
if (formHTML && this.baseUrl === "file") {
formHTML.style.width = "50%";
} else if (formHTML) {
formHTML.style.width = "100%";
}

// console.log("end of mounted: mediaSource = " + self.entity.mediaSource);
// console.log("end of mounted: mediaType = " + self.entity.mediaType);
},
};
</script>
Expand Down
2 changes: 0 additions & 2 deletions src/components/entity/ItemSearch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@

<script>
import Search from "@/components/shared/Search.vue";
import WorkflowResultService from "../../service/workflow-result-service";
import Loader from "@/components/shared/Loader.vue";
import ItemService from "../../service/item-service";

Expand All @@ -52,7 +51,6 @@ export default {
},
data() {
return {
workflowResultService: new WorkflowResultService(),
itemService: new ItemService(),
loading: false,
searchType: "",
Expand Down
57 changes: 8 additions & 49 deletions src/components/shared/Search.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1027,7 +1027,11 @@ export default {
);
break;
case "item-search": {
// since item search by keyword returns a list of items each with all parents IDs
// there is no need to do extra fetching for entity details along the chain at this point
// rather, the details can be fetched later upon request for a sepcific parent entity detail page
console.log("item-search: selectedItemId: ", this.selectedItem.id, "selectedCollectionId: ", this.selectedCollection.id, "selectedUnitId: ", this.selectedUnit.id);
// update currentUnit
let uEntity = JSON.parse(
sessionStorage.getItem("unitEntity")
);
Expand All @@ -1038,56 +1042,11 @@ export default {
"unitEntity",
JSON.stringify({ ...uEntity })
);
// checking permission
// check permission
if (uEntity && uEntity.currentUnit)
self.accessControlService.checkAccessControl(self);
// go to item detail page
self.$router.push("/collections/items/item-search/details");
// this.itemService
// .getItemDetails(this.selectedItemId)
// .then((res) => {
// const self = this;
// const selectedCollectionId = res._embedded.collection.id;
// self.collectionDetailsService
// .getCollection(selectedCollectionId)
// .then((response) => {
// self.selectedCollection = response.data;
// //Updating unit id in our session storage for content page
// const unitId = response.data._embedded.unit.id;
// let uEntity = JSON.parse(
// sessionStorage.getItem("unitEntity")
// );
// uEntity = uEntity || {};
// console.log("Search: uEntity = " + uEntity);
// uEntity.currentUnit = unitId;
// sessionStorage.setItem(
// "unitEntity",
// JSON.stringify({ ...uEntity })
// );
// //checking permission
// if (uEntity && uEntity.currentUnit)
// self.accessControlService.checkAccessControl(self);
// });
// self.selectedItem = res;
// self.selectedItem.parentType = self.type;
// self.selectedItem.unitName = self.selectedUnit.name;
// self.selectedItem.collectionName = self.selectedCollection.name;
// self.$router.push("/collections/items/item-search/details");
// })
// .catch((error) => {
// this.dataSource = [];
// this.clonedDataSource = [];
// this.searchWord = "";
// this.selectedItemId = null;
// this.errors.search_error = "";
// this.errors.no_data_error = "";
// this.$bvToast.toast("Failed to show the item", {
// title: "Notification",
// appendToast: true,
// variant: "danger",
// autoHideDelay: 5000,
// });
// });
this.accessControlService.checkAccessControl(this);
// go to item detail page (upon which point the item detail info shall be fetched in EntityList)
this.$router.push("/collections/items/item-search/details");
break;
}
case "workflow-search":
Expand Down
14 changes: 10 additions & 4 deletions src/components/supplement/SupplementFile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -340,15 +340,21 @@ export default {
const self = this;
try {
self.loading = true;
const configPropertiesResponse = await self.configPropertiesService.getConfigProperties();
self.configProperties = configPropertiesResponse.data;

// retrieve configProperties if not yet done
if (!self.configProperties || Object.keys(self.configProperties).length === 0) {
self.configProperties = await self.configPropertiesService.getConfigProperties();
}

// retrieve accessible units for create/update
await self.accessControlService.getPermissionsUnits("Create", "Supplement").then((res) => {
self.allUnits = res.data;
self.supplement["allUnits"] = self.sharedService.sortByAlphabatical(self.allUnits);
self.canCreate = self.acIsAdmin || res.data && res.data.length > 0
self.canUpdate = self.acIsAdmin || self.action !== "view" && self.canCreate;
self.loading = false;
self.canUpdate = self.acIsAdmin || self.action !== "view" && self.canCreate;
});

self.loading = false;
} catch (error) {
self.loading = false;
console.log(error);
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 @@ -7,6 +7,6 @@ export default class ConfigPropertiesService extends BaseService {
*/

async getConfigProperties() {
return super.get_auth(`/config`);
return super.get_auth(`/config`).then(result => result.data);
}
}
Loading