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