Commit 4187e0fb authored by Reza Sahebgharan's avatar Reza Sahebgharan

feat(disallow to remove hislink and client): disallow to remove hislink and client

disallow to remove hislink and client when have relationship
parent b35c6315
Pipeline #1076 passed with stage
in 41 minutes and 46 seconds
......@@ -5,7 +5,7 @@
<v-btn color="pink" @click="deleteClient">{{$t("Client.YesBtn")}}</v-btn>
<v-btn color="pink" @click="snackbar = false">{{$t("Client.NoBtn")}}</v-btn>
</v-snackbar>
<v-snackbar color="primary" v-model="alertSnackbar" :timeout="2000">{{alertText}}</v-snackbar>
<v-snackbar :color="alertColor" v-model="alertSnackbar" :timeout="2000">{{alertText}}</v-snackbar>
<v-dialog v-model="dialog" max-width="600px">
<v-card>
<v-card-title>
......@@ -49,13 +49,27 @@
<v-card-actions>
<v-row style="margin:auto">
<v-col cols="12" class="d-flex justify-center align-center flex-wrap">
<v-btn color="rgb(94, 181, 177,.85)" class="white--text ma-1" @click="openNewDialog">
<v-btn
color="rgb(94, 181, 177,.85)"
class="white--text ma-1"
@click="openNewDialog"
>
<strong>{{$t("HISLink.newBtn")}}</strong>
</v-btn>
<v-btn color="rgb(94, 181, 177,.85)" class="white--text ma-1" @click="openEditDialog" :disabled="this.selectedItemInTable.length == 0">
<v-btn
color="rgb(94, 181, 177,.85)"
class="white--text ma-1"
@click="openEditDialog"
:disabled="this.selectedItemInTable.length == 0"
>
<strong>{{$t("HISLink.editBtn")}}</strong>
</v-btn>
<v-btn color="rgb(94, 181, 177,.85)" class="white--text ma-1" @click="deleteSnackbar" :disabled="this.selectedItemInTable.length == 0">
<v-btn
color="rgb(94, 181, 177,.85)"
class="white--text ma-1"
@click="deleteSnackbar"
:disabled="this.selectedItemInTable.length == 0"
>
<strong>{{$t("HISLink.deleteBtn")}}</strong>
</v-btn>
</v-col>
......@@ -123,6 +137,7 @@ export default {
snackbar: false,
alertSnackbar: false,
alertText: "",
alertColor:"primary",
loading: false,
search: ""
};
......@@ -209,8 +224,15 @@ export default {
let deleteHislink = {};
deleteHislink._id = this.selectedItemInTable[0]["_id"];
Meteor.call("deleteClient", deleteHislink, function() {
me.alertSnackbarMethod(this.$t("Client.clientDeleteStatement"));
Meteor.call("deleteClient", deleteHislink, function(error, result) {
if (error.reason == "relationShipError") {
me.alertColor = "error";
me.alertSnackbar = true;
me.alertText = me.$t("Client.clientRelationshipError");
return;
}
me.alertSnackbarMethod(me.$t("Client.clientDeleteStatement"));
});
},
deleteSnackbar() {
......
......@@ -69,13 +69,27 @@
<v-card-actions>
<v-row style="margin:auto">
<v-col cols="12" class="d-flex justify-center align-center flex-wrap">
<v-btn color="rgb(94, 181, 177,.85)" class="white--text ma-1" @click="openNewDialog">
<v-btn
color="rgb(94, 181, 177,.85)"
class="white--text ma-1"
@click="openNewDialog"
>
<strong>{{$t("HISLink.newBtn")}}</strong>
</v-btn>
<v-btn color="rgb(94, 181, 177,.85)" class="white--text ma-1" @click="openEditDialog" :disabled="this.selectedItemInTable.length == 0">
<v-btn
color="rgb(94, 181, 177,.85)"
class="white--text ma-1"
@click="openEditDialog"
:disabled="this.selectedItemInTable.length == 0"
>
<strong>{{$t("HISLink.editBtn")}}</strong>
</v-btn>
<v-btn color="rgb(94, 181, 177,.85)" class="white--text ma-1" @click="deleteSnackbar" :disabled="this.selectedItemInTable.length == 0">
<v-btn
color="rgb(94, 181, 177,.85)"
class="white--text ma-1"
@click="deleteSnackbar"
:disabled="this.selectedItemInTable.length == 0"
>
<strong>{{$t("HISLink.deleteBtn")}}</strong>
</v-btn>
</v-col>
......@@ -140,9 +154,10 @@ export default {
DevicemapForm: {
GroupName: "",
CodeInHIS: "",
CodeInPacs: "",
// CodeInPacs: "",
Modality: "",
HisLinkId: "",
ClientId: "",
MaxLen: 0,
_id: ""
},
......@@ -158,7 +173,8 @@ export default {
let headers = [
"GroupName",
"CodeInHIS",
"CodeInPacs",
// "CodeInPacs",
"Client",
"Modality",
"HisName"
];
......@@ -183,13 +199,29 @@ export default {
{ _id: devicemap.HisLinkId },
{ fields: { Name: 1 } }
).fetch();
if (
hislink != undefined &&
hislink != null &&
// hislink.length > 0 &&
hislink[0].Name != undefined
)
currentDevicemap.push({ ...devicemap, HisName: hislink[0].Name });
devicemap = { ...devicemap, HisName: hislink[0].Name };
let client = Client.find(
{ _id: devicemap.ClientId },
{ fields: { Caption: 1 } }
).fetch();
if (
client != undefined &&
client != null &&
// hislink.length > 0 &&
client[0].Caption != undefined
)
devicemap = { ...devicemap, Client: client[0].Caption };
currentDevicemap.push({ ...devicemap });
}
return currentDevicemap;
......@@ -250,9 +282,13 @@ export default {
this.selectedClient = undefined;
this.selectedHisLink = undefined;
let me = this;
this.selectedClient = this.clients.filter(client => {
return client.Caption == me.DevicemapForm.CodeInPacs;
})[0];
// this.selectedClient = this.clients.filter(client => {
// return client._id == me.DevicemapForm.ClientId;
// })[0];
this.selectedClient = Client.find({
_id: me.DevicemapForm.ClientId
}).fetch()[0];
this.selectedHisLink = HisLink.find({
_id: me.DevicemapForm.HisLinkId
......@@ -267,7 +303,7 @@ export default {
let me = this;
if (this.newOrEdit == "new") {
if (this.selectedClient != undefined && this.selectedClient != null)
this.DevicemapForm.CodeInPacs = this.selectedClient.Caption;
this.DevicemapForm.ClientId = this.selectedClient._id;
if (this.selectedHisLink != undefined && this.selectedHisLink != null) {
this.DevicemapForm.HisLinkId = this.selectedHisLink._id;
......@@ -277,7 +313,7 @@ export default {
}
if (this.newOrEdit == "edit") {
if (this.selectedClient != undefined && this.selectedClient != null)
this.DevicemapForm.CodeInPacs = this.selectedClient.Caption;
this.DevicemapForm.ClientId = this.selectedClient._id;
if (this.selectedHisLink != undefined && this.selectedHisLink != null) {
this.DevicemapForm.HisLinkId = this.selectedHisLink._id;
......
......@@ -5,7 +5,7 @@
<v-btn color="pink" @click="deleteHislink">{{$t("HISLink.YesBtn")}}</v-btn>
<v-btn color="pink" @click="snackbar = false">{{$t("HISLink.NoBtn")}}</v-btn>
</v-snackbar>
<v-snackbar color="primary" v-model="alertSnackbar" :timeout="2000">{{alertText}}</v-snackbar>
<v-snackbar :color="alertColor" v-model="alertSnackbar" :timeout="2000">{{alertText}}</v-snackbar>
<v-dialog v-model="dialog" max-width="600px">
<v-card>
<v-card-title>
......@@ -97,7 +97,11 @@
<v-card-actions>
<v-row style="margin:auto">
<v-col cols="12" class="d-flex justify-center align-center flex-wrap">
<v-btn color="rgb(94, 181, 177,.85)" class="white--text ma-1" @click="openNewDialog">
<v-btn
color="rgb(94, 181, 177,.85)"
class="white--text ma-1"
@click="openNewDialog"
>
<strong>{{$t("HISLink.newBtn")}}</strong>
</v-btn>
<v-btn
......@@ -194,7 +198,7 @@
:HisWorklistDialogProp="HisWorklistDialog"
:closeDialog="closeHisWorklistMethod"
:selectedBrand="selectedBrand"
></his-worklist> -->
></his-worklist>-->
</v-container>
</template>
<script>
......@@ -231,6 +235,7 @@ export default {
snackbar: false,
alertSnackbar: false,
alertText: "",
alertColor: "primary",
loading: false,
// HisWorklistDialog: false,
selectedBrand: null,
......@@ -325,7 +330,7 @@ export default {
let me = this;
this.loading = true;
if (this.newOrEdit == "new") {
Meteor.call("createHisLink", this.HisLinkForm, function() {
Meteor.call("createHisLink", this.HisLinkForm, function(error, result) {
// me.dialog = false;
});
}
......@@ -346,7 +351,16 @@ export default {
let deleteHislink = {};
deleteHislink._id = this.selectedItemInTable[0]["_id"];
Meteor.call("deleteHisLink", deleteHislink, function() {
Meteor.call("deleteHisLink", deleteHislink, function(error, result) {
if (error) {
if (error.reason == "relationShipError") {
me.alertColor = "error";
me.alertSnackbar = true;
me.alertText = me.$t("HISLink.hislinkRelationshipError");
return;
}
}
me.alertSnackbarMethod(me.$t("HISLink.hislinkDeleteStatement"));
});
},
......@@ -354,6 +368,7 @@ export default {
this.snackbar = true;
},
alertSnackbarMethod(text) {
me.alertColor = "primary";
this.alertText = text;
this.alertSnackbar = true;
},
......
......@@ -97,7 +97,8 @@ const messages = {
hislinkActiveStatement: "HisLink has been activated",
hislinkDeactiveStatement: "HisLink has been deactivated",
hislinkAuthenticateFailed: "authenticate failed",
hislinkAuthenticateSuccess: "authenticate success"
hislinkAuthenticateSuccess: "authenticate success",
hislinkRelationshipError: "selected HisLink have been linked to a devicemap"
},
Client: {
DeleteMessage: "Are You Sure?",
......@@ -110,6 +111,7 @@ const messages = {
editBtn: "Edit",
clientSelectStatement: "please select one of Clients",
clientDeleteStatement: "Client has been deleted",
clientRelationshipError: "selected Client have been linked to a devicemap"
},
DeviceMap: {
DeleteMessage: "Are You Sure?",
......@@ -279,7 +281,8 @@ const messages = {
hislinkActiveStatement: "HISLink فعال شد",
hislinkDeactiveStatement: "HISLink غیرفعال شد",
hislinkAuthenticateFailed: "authenticate failed",
hislinkAuthenticateSuccess: "authenticate success"
hislinkAuthenticateSuccess: "authenticate success",
hislinkRelationshipError: "درگاه انتخاب شده دارای یک نگاشت می باشد"
},
Client: {
DeleteMessage: "آیا مطمین هستید؟",
......@@ -292,6 +295,7 @@ const messages = {
editBtn: "ویرایش",
clientSelectStatement: "لطفا یکی از Client ها را انتخاب نمایید",
clientDeleteStatement: "Client حذف گردید",
clientRelationshipError: "دستگاه انتخاب شده دارای یک نگاشت می باشد"
},
DeviceMap: {
DeleteMessage: "آیا مطمین هستید؟",
......
......@@ -2,6 +2,8 @@ import { Meteor } from 'meteor/meteor';
import { check } from 'meteor/check';
import { HTTP } from 'meteor/http';
import DeviceMap from '../collections/devicemap.js'
Meteor.methods({
'createClient' (item) {
......@@ -46,6 +48,11 @@ Meteor.methods({
},
"deleteClient" (item) {
this.unblock();
let relationShipCount = DeviceMap.find({ ClientId: item._id }).count();
if (relationShipCount > 0) {
throw new Meteor.Error(500, "relationShipError");
}
if (this.userId) {
try {
let options = {
......
......@@ -2,6 +2,8 @@ import { Meteor } from 'meteor/meteor';
import { check } from 'meteor/check';
import { HTTP } from 'meteor/http';
import DeviceMap from '../collections/devicemap.js'
Meteor.methods({
'createHisLink' (item) {
......@@ -9,6 +11,7 @@ Meteor.methods({
if (this.userId) {
try {
let options = {
data: item,
headers: {
......@@ -53,7 +56,16 @@ Meteor.methods({
"deleteHisLink" (item) {
this.unblock();
if (this.userId) {
let relationShipCount = DeviceMap.find({ HisLinkId: item._id }).count();
if (relationShipCount > 0) {
throw new Meteor.Error(500, "relationShipError");
}
try {
let options = {
data: item,
headers: {
......@@ -68,7 +80,7 @@ Meteor.methods({
} catch (e) {
// Got a network error, timeout, or HTTP error in the 400 or 500 range.
console.log(e);
return false;
return e.reason;
}
}
},
......
This diff is collapsed.
......@@ -69,7 +69,6 @@
"meteor-jest-stubs": "^2.0.0",
"sass": "^1.22.9",
"sass-loader": "^7.2.0",
"standard-version": "^7.0.0",
"uglifyjs-webpack-plugin": "^2.2.0",
"vue-jest": "^3.0.5",
......@@ -110,4 +109,4 @@
"!**/__mock__/**"
]
}
}
\ No newline at end of file
}
......@@ -170,11 +170,12 @@ const clientConfig = {
performance: {
hints: false
},
devtool: process.env.NODE_ENV == 'production' ? '' : 'source-map',
devtool: process.env.NODE_ENV == 'production' ? '' : 'eval-source-map',
plugins: [
new webpack.HotModuleReplacementPlugin(),
new HtmlWebpackPlugin({
template: './client/main.html'
template: './client/main.html',
}),
new VueLoaderPlugin(),
new webpack.DefinePlugin({
......@@ -206,7 +207,7 @@ const serverConfig = {
hot: true,
open: true
},
devtool: process.env.NODE_ENV == 'production' ? '' : 'source-map',
devtool: process.env.NODE_ENV == 'production' ? '' : 'eval-source-map',
mode: process.env.NODE_ENV,
module: {
rules: [{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment