PMCORE-3113:UI - Import a custom Case list JSON

COrrection
This commit is contained in:
fabio
2021-08-23 20:17:07 -04:00
parent f848c131b8
commit 50de512dfb
6 changed files with 255 additions and 15 deletions

View File

@@ -79,6 +79,20 @@ class caseListApi extends Api {
data: data
});
}
importCaseList(data) {
let formData = new FormData();
formData.append('file_content', data.file);
if (data.continue) {
formData.append(data.continue, 'continue');
}
return this.post({
service: "IMPOR_CASE_LIST",
data: formData,
headers:{
'Content-Type': 'multipart/form-data'
},
})
}
}
let api = new caseListApi(Services);

View File

@@ -6,5 +6,6 @@ export default {
REPORT_TABLES: "/caseList/report-tables",
CASE_LIST: "/caseList",
DEFAULT_COLUMNS: "/caseList/{type}/default-columns",
PUT_CASE_LIST: "/caseList/{id}"
PUT_CASE_LIST: "/caseList/{id}",
IMPOR_CASE_LIST: "/caseList/import"
};

View File

@@ -681,15 +681,16 @@ export default {
*/
getDefaultColumns(type) {
let that = this;
if (!this.params.columns) {
Api.getDefault(type)
.then((response) => {
Api.getDefault(type)
.then((response) => {
if (!that.params.columns) {
that.dataCaseList = response.data;
})
.catch((e) => {
console.error(e);
})
}
}
that.defaultCaseList = response.data;
})
.catch((e) => {
console.error(e);
})
}
},
};

View File

@@ -2,6 +2,7 @@
<div id="people">
<ModalDeleteCaseList ref="modal-delete-list"></ModalDeleteCaseList>
<ModalPreview ref="modal-preview"></ModalPreview>
<ModalImport ref="modal-import"></ModalImport>
<button-fleft :data="newList"></button-fleft>
<button-fleft :data="importList"></button-fleft>
<v-server-table
@@ -29,6 +30,7 @@ import utils from "../../../utils/utils";
import OwnerCell from "../../../components/vuetable/OwnerCell";
import ModalDeleteCaseList from "./../../Modals/ModalDeleteCaseList.vue";
import ModalPreview from "./../../Modals/ModalPreview.vue";
import ModalImport from "./../../Modals/ModalImport.vue";
import download from "downloadjs";
export default {
@@ -40,6 +42,7 @@ export default {
OwnerCell,
ModalDeleteCaseList,
ModalPreview,
ModalImport,
},
data() {
return {
@@ -69,7 +72,7 @@ export default {
title: this.$i18n.t("Import List"),
class: "btn-success",
onClick: () => {
//TODO button
this.importCustomCaseList();
}
},
columns: [
@@ -235,8 +238,32 @@ export default {
*/
downloadCaseList(data) {
var fileName = data.name,
typeMime = "text/plain";
download(JSON.stringify(data), fileName + ".json", typeMime);
typeMime = "text/plain",
dataExport = [];
dataExport = this.filterDataToExport(data);
download(JSON.stringify(dataExport), fileName + ".json", typeMime);
},
/**
* Filter the sensible information to export
* @param {Array} data
*/
filterDataToExport(data) {
var dataExport = [];
dataExport.push({
type: data['type'],
name: data['name'],
description: data['description'],
tableUid: data['tableUid'],
tableName: data['tableName'],
columns: data['columns'],
userId: data['userId'],
iconList: data['iconList'],
iconColor: data['iconColor'],
iconColorScreen: data['iconColorScreen'],
createDate: data['createDate'],
updateDate: data['updateDate']
});
return dataExport;
},
/**
* Show options in the ellipsis
@@ -282,6 +309,14 @@ export default {
}
}
},
importCustomCaseList() {
this.$refs["modal-import"].show();
}
}
};
</script>
</script>
<style>
.float-right {
padding-left: 1.5%;
}
</style>