Commit 7f6011b6 authored by ZeMKI's avatar ZeMKI
Browse files

small javascript code optimization

parent b6f441f3
...@@ -110,6 +110,7 @@ table { ...@@ -110,6 +110,7 @@ table {
color: #046cbe; color: #046cbe;
display: block; display: block;
line-height: 1.5; line-height: 1.5;
font-size: 16px;
} }
   
/* BACKGROUND /* BACKGROUND
......
...@@ -110,6 +110,7 @@ table { ...@@ -110,6 +110,7 @@ table {
color: #046cbe; color: #046cbe;
display: block; display: block;
line-height: 1.5; line-height: 1.5;
font-size: 16px;
} }
/* BACKGROUND /* BACKGROUND
......
This diff is collapsed.
{ {
"/js/app.js": "/js/app.js?id=8335407ff7be9f367e83", "/js/app.js": "/js/app.js?id=877c470a605478b522ac",
"/css/app.css": "/css/app.css?id=1abf25588c73d17b8451", "/css/app.css": "/css/app.css?id=e850b5c60370c59e1f2d",
"/css/app_dompdf.css": "/css/app_dompdf.css?id=06023e8a43967827a614", "/css/app_dompdf.css": "/css/app_dompdf.css?id=473a4745658ee6ec7590",
"/js/manifest.js": "/js/manifest.js?id=844cdbfe9e6b6b56ae8f", "/js/manifest.js": "/js/manifest.js?id=844cdbfe9e6b6b56ae8f",
"/js/vendor.js": "/js/vendor.js?id=e803732b0abd596f50d8" "/js/vendor.js": "/js/vendor.js?id=e803732b0abd596f50d8"
} }
...@@ -25,7 +25,7 @@ Vue.component('v-select', vSelect) ...@@ -25,7 +25,7 @@ Vue.component('v-select', vSelect)
*/ */
Vue.component('new-study', require('./components/newstudy.vue').default); Vue.component('new-study', require('./components/newstudy.vue').default);
Vue.component('new-edit-user', require('./components/newedituser.vue').default); Vue.component('new-edit-user', require('./components/modalnewedituser.vue').default);
Vue.component('user-overview', require('./components/overviewuser.vue').default); Vue.component('user-overview', require('./components/overviewuser.vue').default);
Vue.component('new-interview', require('./components/newinterview.vue').default); Vue.component('new-interview', require('./components/newinterview.vue').default);
Vue.component('sorting', require('./components/sorting.vue').default); Vue.component('sorting', require('./components/sorting.vue').default);
...@@ -41,28 +41,6 @@ var bus = new Vue(); ...@@ -41,28 +41,6 @@ var bus = new Vue();
// Assign globally functions for getCookies and setCookies in JS // Assign globally functions for getCookies and setCookies in JS
Vue.mixin({ Vue.mixin({
data() {
return {
fromidtoname: {
permissionsNames: {
1: "Only consult data",
2: "Can edit study",
3: "Can assign users to study",
4: "Can edit and create users",
5: "Can edit and create studies",
6: "Creator of the study"
},
permissionsVariables: {
onlyconsult: 1,
caneditstudy: 2,
canassignusers: 3,
cancreateusers: 4,
cancreatestudy: 5,
creator: 6
}
}
}
},
computed: { computed: {
url: function () { url: function () {
return document.URL.split('/').pop(); return document.URL.split('/').pop();
......
<template>
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card card-default">
<div class="card-header">Example Component</div>
<div class="card-body">
I'm an example component.
</div>
</div>
</div>
</div>
</div>
</template>
<script>
export default {
mounted() {
console.log('Component mounted.')
}
}
</script>
...@@ -138,11 +138,6 @@ ...@@ -138,11 +138,6 @@
studiesselected: [], studiesselected: [],
supervisorselected: [], supervisorselected: [],
allpermissions: [], allpermissions: [],
permissions: {
onlyconsult: false,
caneditstudy: false,
canassignusers: false
},
globalpermissions:{ globalpermissions:{
cancreateusers: false, cancreateusers: false,
cancreatestudy: false cancreatestudy: false
...@@ -211,7 +206,8 @@ ...@@ -211,7 +206,8 @@
4: "cancreateusers", 4: "cancreateusers",
5: "cancreatestudy", 5: "cancreatestudy",
6: "creator" 6: "creator"
} };
for (var permission in val){ for (var permission in val){
self.studiesselected[self.studyradio][permission] = val[permission]; self.studiesselected[self.studyradio][permission] = val[permission];
} }
...@@ -263,7 +259,7 @@ ...@@ -263,7 +259,7 @@
"onlyconsult", "onlyconsult",
"caneditstudy", "caneditstudy",
"canassignusers" "canassignusers"
] ];
/// if the study doesn't exist, initialize with all false values /// if the study doesn't exist, initialize with all false values
/// otherwise assign the values to the 3 permissions checkboxes /// otherwise assign the values to the 3 permissions checkboxes
...@@ -289,53 +285,7 @@ ...@@ -289,53 +285,7 @@
window.axios.post('getinputdata').then(response =>{ window.axios.post('getinputdata').then(response =>{
this.inputs.userroles = response.data.allroles; this.inputs.userroles = response.data.allroles;
// this.inputs.studies = response.data.relatedstudies;
// if(!_.isEmpty(response.data.supervisors)) this.inputs.supervisors = response.data.supervisors;
// show the placeholder
this.userroleselected = 3; this.userroleselected = 3;
/*
UPDATE FUNCTION FOR USERS
if(this.update){
window.axios.get('user/'+this.edituser,{data: this.edituser}).then(response =>{
this.usertoedit = response.data;
this.email = this.usertoedit.email;
for (var i = 0; i < this.usertoedit.roles.length; i++) {
this.userroleselected = this.usertoedit.roles[i].id;
}
// for (var i = 0; i < this.usertoedit.studies.length; i++) {
// this.studiesselected.push(this.usertoedit.studies[i].id);
// }
let permissions = [];
for (var i = 0; i < this.usertoedit.studies.length; i++) {
let id = this.usertoedit.studies[i].id;
if(_.isUndefined(this.studiesselected[id])){
this.studiesselected[id] = {}
for (var i = 0; i < this.usertoedit.studies[i].pivot.permission_id.length; i++) {
this.studiesselected[id][this.fromidtoname.permissionsNames[this.usertoedit.studies[i].pivot.permission_id[i]]] = true
}
}else{
for (var i = 0; i < this.usertoedit.studies[i].pivot.permission_id.length; i++) {
this.studiesselected[id][this.fromidtoname.permissionsNames[this.usertoedit.studies[i].pivot.permission_id[i]]] = true
}
}
}
this.studiesselected = this.allpermissions;
if(this.inputs.supervisors) this.supervisorselected = this.usertoedit.supervised_by;
}).catch(error =>{
});
}*/
}).catch(error =>{ }).catch(error =>{
console.log("error "+error); console.log("error "+error);
...@@ -348,11 +298,6 @@ ...@@ -348,11 +298,6 @@
saveuser: function(){ saveuser: function(){
// let gpermissions = [];
// if(this.globalpermissions.cancreatestudy)gpermissions.push(4);
// if(this.globalpermissions.cancreateusers)gpermissions.push(5);
let activeStudies = this.study; let activeStudies = this.study;
if(this.validate()){ if(this.validate()){
...@@ -413,7 +358,6 @@ emptyform: function() { ...@@ -413,7 +358,6 @@ emptyform: function() {
this.emailexistmessage =""; this.emailexistmessage ="";
this.userroleselected = []; this.userroleselected = [];
this.studiesselected = []; this.studiesselected = [];
this.resetspecificpermissions();
}, },
sendresetpassworddialog() { sendresetpassworddialog() {
...@@ -435,26 +379,11 @@ sendresetopassword() { ...@@ -435,26 +379,11 @@ sendresetopassword() {
}); });
}, },
resetallpermissions: function(){ resetallpermissions: function(){
this.permissions.onlyconsult = false; this.globalpermissions.cancreateusers = false;
this.permissions.caneditstudy = false; this.globalpermissions.cancreatestudy = false;
this.permissions.canassignusers = false;
this.globalpermissions.cancreateusers = false;
this.globalpermissions.cancreatestudy = false;
}, }
resetspecificpermissions: function(){
this.permissions.onlyconsult = false;
this.permissions.caneditstudy = false;
this.permissions.canassignusers = false;
},
loadpermissions: function(id){
this.createStudyPermissionArray(id)
this.studyradio = id;
}
} }
} }
......
...@@ -4,18 +4,18 @@ ...@@ -4,18 +4,18 @@
<div class="column" v-for="user in usersinstudy" v-if="user['email'] != 'belli@uni-bremen.de' && user['email'] != auth['email'] "> <div class="column" v-for="user in usersinstudy" v-if="user['email'] != 'belli@uni-bremen.de' && user['email'] != auth['email'] ">
<div class="level has-background-light" style="padding: 3px"> <div class="level has-background-light" style="padding: 3px">
<div class="level-left" @click="confirmdeleteuser(user)"><b-icon icon="delete-sweep" class="has-text-danger " ></b-icon></div> <div class="level-left" @click="confirmDeleteUser(user)"><b-icon icon="delete-sweep" class="has-text-danger " ></b-icon></div>
<div class="level-right">{{user['email']}}</div> <div class="level-right">{{user['email']}}</div>
</div> </div>
<div class="level has-background-warning is-size-7" style="padding: 3px" > <div class="level has-background-warning is-size-7" style="padding: 3px" >
<div class="level-left" @click="confirmsendconfirmation(user)"><b-icon icon="send" ></b-icon> Send</div> <div class="level-left" @click="confirmSendConfirmationEmail(user)"><b-icon icon="send" ></b-icon> Send</div>
<div class="level-right" v-if="user['password_token']">This user needs to set a password</div> <div class="level-right" v-if="user['password_token']">This user needs to set a password</div>
<div class="level-right" v-if="!(user['password_token'])">Reset password for this user</div> <div class="level-right" v-if="!(user['password_token'])">Reset password for this user</div>
</div> </div>
<div class="level" v-for="role in user['roles']"> <div class="level" v-for="role in user['roles']">
<div class="level-left"><span class="tag is-primary">{{role['name']}}</span></div> <div class="level-left"><span class="tag is-primary">{{role['name']}}</span></div>
</div> </div>
<label class="checkbox" @change="changeeditpermission(caneditthisstudy[user['id']],user['id'])" :disabled="studyeditable == false"> <label class="checkbox" @change="changeEditPermission(caneditthisstudy[user['id']],user['id'])" :disabled="studyeditable == false">
<input type="checkbox" v-model="caneditthisstudy[user['id']]" :disabled="studyeditable == false"> <input type="checkbox" v-model="caneditthisstudy[user['id']]" :disabled="studyeditable == false">
Can edit <strong>this</strong> study Can edit <strong>this</strong> study
</label> </label>
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
props: ['usersinstudy','study','auth','studyeditable'], props: ['usersinstudy','study','auth','studyeditable'],
data() { data() {
return { return {
caneditthisstudy: {}, caneditthisstudy: {},
cancreatestudies: {} cancreatestudies: {}
} }
...@@ -53,44 +53,35 @@ ...@@ -53,44 +53,35 @@
} }
}, },
event:{
reloadusers: function(){
window.axios.get('study'+this.study+'users').then(response =>{
}).catch(error =>{
});
}
},
methods:{ methods:{
confirmdeleteuser: function(user) { confirmDeleteUser: function(user) {
window.app.$dialog.confirm({ window.app.$dialog.confirm({
title: 'Delete User', title: 'Delete User',
message: 'Do you want to delete this user? '+user.email, message: 'Do you want to delete this user? '+user.email,
confirmText: 'Delete', confirmText: 'Delete',
type: 'is-danger', type: 'is-danger',
hasIcon: true, hasIcon: true,
onConfirm: () => this.deleteuser(user) onConfirm: () => this.deleteUser(user)
}) })
}, },
confirmsendconfirmation: function(user) { confirmSendConfirmationEmail: function(user) {
window.app.$dialog.confirm({ window.app.$dialog.confirm({
title: 'Reset User Password', title: 'Reset User Password',
message: 'Do you want to send again the confirmation email to this user? '+user.email, message: 'Do you want to send again the confirmation email to this user? '+user.email,
confirmText: 'Resend', confirmText: 'Resend',
type: 'is-warning', type: 'is-warning',
hasIcon: true, hasIcon: true,
onConfirm: () => this.confirmuser(user) onConfirm: () => this.confirmUser(user)
}) })
}, },
confirmuser: function(user){ confirmUser: function(user){
window.axios.patch('usersconfirm/'+user.id).then(response=>{ window.axios.patch('usersconfirm/'+user.id).then(response=>{
window.app.$snackbar.open("User needs to create a new password"); window.app.$snackbar.open("User needs to create a new password");
}).catch(error =>{ }).catch(error =>{
}) })
}, },
deleteuser: function(user){ deleteUser: function(user){
window.axios.post('users/'+user.id+'/'+this.study).then(response=>{ window.axios.post('users/'+user.id+'/'+this.study).then(response=>{
window.app.$snackbar.open("User deleted"); window.app.$snackbar.open("User deleted");
...@@ -102,7 +93,7 @@ ...@@ -102,7 +93,7 @@
}).catch(error =>{ }).catch(error =>{
}) })
}, },
changeeditpermission: function(value,user){ changeEditPermission: function(value,user){
let valueToSend = {'value': value} let valueToSend = {'value': value}
window.axios.post('users/'+user+'/canedit/'+this.study,valueToSend).then(response=>{ window.axios.post('users/'+user+'/canedit/'+this.study,valueToSend).then(response=>{
......
...@@ -37,4 +37,6 @@ ...@@ -37,4 +37,6 @@
color: #046cbe; color: #046cbe;
display: block; display: block;
line-height: 1.5; line-height: 1.5;
font-size:16px;
} }
Supports Markdown
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