Commit e8304e54 authored by ZeMKI's avatar ZeMKI
Browse files

Create a supervisor in the backend

* now there's a user interface to activate supervisors
* you can send test emails to check what's in there
* default text in app/utilities
* bugfixed keyenter 13 that was active on the whole website instead of only the interview
parent 5d142e17
...@@ -52,10 +52,15 @@ class CreateUserCommand extends Command ...@@ -52,10 +52,15 @@ class CreateUserCommand extends Command
if ($this->store($role, $email, $user)) { if ($this->store($role, $email, $user)) {
Mail::to($email)->send(new VerificationEmail($user)); Mail::to($email)->send(new VerificationEmail($user,config('utilities.emailDefaultText')));
$this->info('An email was sent to '.$user->email.' he/she needs to set the password.');
return true; return true;
} else } else
{
$this->info('There it was an error during user creation, please try again.');
return false; return false;
}
} }
......
...@@ -178,6 +178,10 @@ class UserController extends Controller ...@@ -178,6 +178,10 @@ class UserController extends Controller
{ {
// case from admin area // case from admin area
if($request->testEmail){
Mail::to($request->email)->send(new VerificationEmail(new User,$request->emailtext? $request->emailtext : config('utilities.emailDefaultText')));
return redirect('/admin/supervisor')->with(['message'=>'Test Email sent to '.$request->email]);
}
$editpermissions = Permission::where('name', 'like', '%interviews')->get()->toArray(); $editpermissions = Permission::where('name', 'like', '%interviews')->get()->toArray();
...@@ -202,16 +206,17 @@ class UserController extends Controller ...@@ -202,16 +206,17 @@ class UserController extends Controller
// supervisor create a researcher // supervisor create a researcher
$user->supervised_by = Auth::user()->id; $user->supervised_by = Auth::user()->id;
Mail::to($user->email)->send(new VerificationEmail($user));
$user->save(); $user->save();
$user->attachRole($role, $study); $user->attachRole($role, $study);
Mail::to($user->email)->send(new VerificationEmail($user,$request->emailtext? $request->emailtext : config('utilities.emailDefaultText')));
} }
$user->attachPermissions($editpermissions, $study); $user->attachPermissions($editpermissions, $study);
return response("An email verification was sent to " . $user->email . " please let the user open it"); if(!$request->emailtext)return response("An email verification was sent to " . $user->email . " please let the user open it");
else return redirect('/admin/supervisor')->with(['message'=>'User registered']);
} }
......
...@@ -16,9 +16,10 @@ class VerificationEmail extends Mailable ...@@ -16,9 +16,10 @@ class VerificationEmail extends Mailable
* *
* @return void * @return void
*/ */
public function __construct(User $user) public function __construct(User $user, $emailtext)
{ {
$this->user = $user; $this->user = $user;
$this->emailtext = $emailtext;
} }
/** /**
...@@ -28,6 +29,6 @@ class VerificationEmail extends Mailable ...@@ -28,6 +29,6 @@ class VerificationEmail extends Mailable
*/ */
public function build() public function build()
{ {
return $this->from('noreply@kommunikative-figurationen.de')->markdown('email.setpassword')->with(['user' => $this->user]); return $this->from('no_reply@kommunikative-figurationen.de')->markdown('email.setpassword')->with(['user' => $this->user, 'text' => $this->emailtext]);
} }
} }
This diff is collapsed.
...@@ -734,12 +734,7 @@ __webpack_require__.r(__webpack_exports__); ...@@ -734,12 +734,7 @@ __webpack_require__.r(__webpack_exports__);
// //
// //
// //
$(document).on('keydown', function (e) { // record animation
if (e.keyCode == 13) {
e.preventDefault();
}
}); // record animation
$(document).ready(function () { $(document).ready(function () {
var divs = $('*[class^="rect"]'); var divs = $('*[class^="rect"]');
   
...@@ -808,7 +803,12 @@ $(document).ready(function () { ...@@ -808,7 +803,12 @@ $(document).ready(function () {
} }
}, },
mounted: function mounted() { mounted: function mounted() {
// Prevent pull refresh chrome $(document).on('keydown', function (e) {
if (e.keyCode == 13) {
e.preventDefault();
}
}); // Prevent pull refresh chrome
var lastTouchY = 0; var lastTouchY = 0;
var preventPullToRefresh = false; var preventPullToRefresh = false;
window.document.body.addEventListener("touchstart", function (e) { window.document.body.addEventListener("touchstart", function (e) {
...@@ -16686,15 +16686,12 @@ __webpack_require__.r(__webpack_exports__); ...@@ -16686,15 +16686,12 @@ __webpack_require__.r(__webpack_exports__);
/* harmony import */ var buefy__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(buefy__WEBPACK_IMPORTED_MODULE_0__); /* harmony import */ var buefy__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(buefy__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var vue_material_design_icons_styles_css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! vue-material-design-icons/styles.css */ "./node_modules/vue-material-design-icons/styles.css"); /* harmony import */ var vue_material_design_icons_styles_css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! vue-material-design-icons/styles.css */ "./node_modules/vue-material-design-icons/styles.css");
/* harmony import */ var vue_material_design_icons_styles_css__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(vue_material_design_icons_styles_css__WEBPACK_IMPORTED_MODULE_1__); /* harmony import */ var vue_material_design_icons_styles_css__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(vue_material_design_icons_styles_css__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var interactjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! interactjs */ "./node_modules/interactjs/dist/interact.js"); /* harmony import */ var vue_material_design_icons_Plus_vue__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! vue-material-design-icons/Plus.vue */ "./node_modules/vue-material-design-icons/Plus.vue");
/* harmony import */ var interactjs__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(interactjs__WEBPACK_IMPORTED_MODULE_2__); /* harmony import */ var vue_material_design_icons_ArrowLeft_vue__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! vue-material-design-icons/ArrowLeft.vue */ "./node_modules/vue-material-design-icons/ArrowLeft.vue");
/* harmony import */ var vue_material_design_icons_Plus_vue__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! vue-material-design-icons/Plus.vue */ "./node_modules/vue-material-design-icons/Plus.vue"); /* harmony import */ var vue_material_design_icons_ArrowRight_vue__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! vue-material-design-icons/ArrowRight.vue */ "./node_modules/vue-material-design-icons/ArrowRight.vue");
/* harmony import */ var vue_material_design_icons_ArrowLeft_vue__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! vue-material-design-icons/ArrowLeft.vue */ "./node_modules/vue-material-design-icons/ArrowLeft.vue"); /* harmony import */ var vue_material_design_icons_Pencil_vue__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! vue-material-design-icons/Pencil.vue */ "./node_modules/vue-material-design-icons/Pencil.vue");
/* harmony import */ var vue_material_design_icons_ArrowRight_vue__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! vue-material-design-icons/ArrowRight.vue */ "./node_modules/vue-material-design-icons/ArrowRight.vue"); /* harmony import */ var vue_select__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! vue-select */ "./node_modules/vue-select/dist/vue-select.js");
/* harmony import */ var vue_material_design_icons_TrashCan_vue__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! vue-material-design-icons/TrashCan.vue */ "./node_modules/vue-material-design-icons/TrashCan.vue"); /* harmony import */ var vue_select__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(vue_select__WEBPACK_IMPORTED_MODULE_6__);
/* harmony import */ var vue_material_design_icons_Pencil_vue__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! vue-material-design-icons/Pencil.vue */ "./node_modules/vue-material-design-icons/Pencil.vue");
/* harmony import */ var vue_select__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! vue-select */ "./node_modules/vue-select/dist/vue-select.js");
/* harmony import */ var vue_select__WEBPACK_IMPORTED_MODULE_8___default = /*#__PURE__*/__webpack_require__.n(vue_select__WEBPACK_IMPORTED_MODULE_8__);
/** /**
* First we will load all of this project's JavaScript dependencies which * First we will load all of this project's JavaScript dependencies which
* includes Vue and other libraries. It is a great starting point when * includes Vue and other libraries. It is a great starting point when
...@@ -16709,10 +16706,8 @@ __webpack_require__(/*! ./bootstrap */ "./resources/js/bootstrap.js"); ...@@ -16709,10 +16706,8 @@ __webpack_require__(/*! ./bootstrap */ "./resources/js/bootstrap.js");
   
   
   
window.Vue = __webpack_require__(/*! vue */ "./node_modules/vue/dist/vue.common.js"); window.Vue = __webpack_require__(/*! vue */ "./node_modules/vue/dist/vue.common.js");
Vue.component('v-select', vue_select__WEBPACK_IMPORTED_MODULE_6___default.a);
Vue.component('v-select', vue_select__WEBPACK_IMPORTED_MODULE_8___default.a);
/** /**
* Next, we will create a fresh Vue application instance and attach it to * Next, we will create a fresh Vue application instance and attach it to
* the page. Then, you may begin adding components to this application * the page. Then, you may begin adding components to this application
...@@ -16828,10 +16823,10 @@ Vue.mixin({ ...@@ -16828,10 +16823,10 @@ Vue.mixin({
window.app = new Vue({ window.app = new Vue({
el: '#app', el: '#app',
components: { components: {
PlusIcon: vue_material_design_icons_Plus_vue__WEBPACK_IMPORTED_MODULE_3__["default"], PlusIcon: vue_material_design_icons_Plus_vue__WEBPACK_IMPORTED_MODULE_2__["default"],
ArrowRight: vue_material_design_icons_ArrowRight_vue__WEBPACK_IMPORTED_MODULE_5__["default"], ArrowRight: vue_material_design_icons_ArrowRight_vue__WEBPACK_IMPORTED_MODULE_4__["default"],
ArrowLeft: vue_material_design_icons_ArrowLeft_vue__WEBPACK_IMPORTED_MODULE_4__["default"], ArrowLeft: vue_material_design_icons_ArrowLeft_vue__WEBPACK_IMPORTED_MODULE_3__["default"],
Pencil: vue_material_design_icons_Pencil_vue__WEBPACK_IMPORTED_MODULE_7__["default"] Pencil: vue_material_design_icons_Pencil_vue__WEBPACK_IMPORTED_MODULE_5__["default"]
}, },
data: { data: {
newstudy: {}, newstudy: {},
{ {
"/js/app.js": "/js/app.js?id=ae086bf49dbc84368c71", "/js/app.js": "/js/app.js?id=3803ce4ea00beb99b3c5",
"/css/app.css": "/css/app.css?id=33e8c8db759d1aed6c23", "/css/app.css": "/css/app.css?id=33e8c8db759d1aed6c23",
"/css/app_dompdf.css": "/css/app_dompdf.css?id=225174786ee9d00fe897", "/css/app_dompdf.css": "/css/app_dompdf.css?id=225174786ee9d00fe897",
"/js/manifest.js": "/js/manifest.js?id=844cdbfe9e6b6b56ae8f", "/js/manifest.js": "/js/manifest.js?id=844cdbfe9e6b6b56ae8f",
......
/** /**
* First we will load all of this project's JavaScript dependencies which * First we will load all of this project's JavaScript dependencies which
* includes Vue and other libraries. It is a great starting point when * includes Vue and other libraries. It is a great starting point when
* building robust, powerful web applications using Vue and Laravel. * building robust, powerful web applications using Vue and Laravel.
*/ */
require('./bootstrap'); require('./bootstrap');
import Buefy from 'buefy' import Buefy from 'buefy'
import "vue-material-design-icons/styles.css" import "vue-material-design-icons/styles.css"
import PlusIcon from "vue-material-design-icons/Plus.vue"
import interact from 'interactjs' import ArrowLeft from "vue-material-design-icons/ArrowLeft.vue"
import PlusIcon from "vue-material-design-icons/Plus.vue" import ArrowRight from "vue-material-design-icons/ArrowRight.vue"
import ArrowLeft from "vue-material-design-icons/ArrowLeft.vue" import Pencil from "vue-material-design-icons/Pencil.vue"
import ArrowRight from "vue-material-design-icons/ArrowRight.vue" import vSelect from 'vue-select'
import TrashCan from "vue-material-design-icons/TrashCan.vue"
import Pencil from "vue-material-design-icons/Pencil.vue"
window.Vue = require('vue'); window.Vue = require('vue');
import vSelect from 'vue-select'
Vue.component('v-select', vSelect) Vue.component('v-select', vSelect)
/** /**
...@@ -27,116 +23,115 @@ Vue.component('v-select', vSelect) ...@@ -27,116 +23,115 @@ Vue.component('v-select', vSelect)
* or customize the JavaScript scaffolding to fit your unique needs. * or customize the JavaScript scaffolding to fit your unique needs.
*/ */
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/newedituser.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);
Vue.component('consultsorting', require('./components/consultsorting.vue').default); Vue.component('consultsorting', require('./components/consultsorting.vue').default);
Vue.component('userpart', require('./components/userpart.vue').default); Vue.component('userpart', require('./components/userpart.vue').default);
Vue.config.devtools = true; Vue.config.devtools = true;
Vue.config.debug = true; Vue.config.debug = true;
Vue.config.silent = false; Vue.config.silent = false;
Vue.use(Buefy) Vue.use(Buefy)
var bus = new Vue(); 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() { data() {
return { return {
fromidtoname:{ fromidtoname: {
permissionsNames:{ permissionsNames: {
1: "Only consult data", 1: "Only consult data",
2: "Can edit study", 2: "Can edit study",
3: "Can assign users to study", 3: "Can assign users to study",
4: "Can edit and create users", 4: "Can edit and create users",
5: "Can edit and create studies", 5: "Can edit and create studies",
6: "Creator of the study" 6: "Creator of the study"
}, },
permissionsVariables:{ permissionsVariables: {
onlyconsult: 1, onlyconsult: 1,
caneditstudy: 2, caneditstudy: 2,
canassignusers: 3, canassignusers: 3,
cancreateusers: 4, cancreateusers: 4,
cancreatestudy: 5, cancreatestudy: 5,
creator: 6 creator: 6
} }
}
}
},
computed: {
url: function () {
return document.URL.split('/').pop();
}
},
methods: {
getCookie: function(cname) {
let name = cname + "=";
let ca = document.cookie.split(';');
for(let i = 0; i < ca.length; i++) {
let c = ca[i];
while (c.charAt(0) == ' ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
} }
} }
return "";
}, },
setCookie: function (cname, cvalue, exdays) { computed: {
let d = new Date(); url: function () {
d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000)); return document.URL.split('/').pop();
let expires = "expires="+d.toUTCString(); }
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
},
deleteCookie: function(name){
document.cookie = name + '=;expires=Thu, 01 Jan 1970 00:00:01 GMT;';
}, },
confirmdelete: function(id, name){ methods: {
getCookie: function (cname) {
this.$dialog.confirm( let name = cname + "=";
{ let ca = document.cookie.split(';');
title: 'Confirm Delete', for (let i = 0; i < ca.length; i++) {
message: `Are you sure to delete the study `+name+' and all the deleted data?', let c = ca[i];
cancelText: 'Cancel', while (c.charAt(0) == ' ') {
confirmText: 'Delete', c = c.substring(1);
type: 'is-danger', }
onConfirm: () => this.deletestudy(id) if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
}
return "";
},
setCookie: function (cname, cvalue, exdays) {
let d = new Date();
d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
let expires = "expires=" + d.toUTCString();
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
},
deleteCookie: function (name) {
document.cookie = name + '=;expires=Thu, 01 Jan 1970 00:00:01 GMT;';
},
confirmdelete: function (id, name) {
this.$dialog.confirm(
{
title: 'Confirm Delete',
message: `Are you sure to delete the study ` + name + ' and all the deleted data?',
cancelText: 'Cancel',
confirmText: 'Delete',
type: 'is-danger',
onConfirm: () => this.deletestudy(id)
}
);
},
deletestudy: function (id) {
this.loading = true;
this.message = "";
let self = this;
axios.delete('studies/' + id, {data: id})
.then(response => {
setTimeout(function () {
self.loading = false;
self.$snackbar.open("Study deleted");
window.location.href = '../mesort';
}, 500);
}).catch(function (error) {
console.log(error);
self.loading = false;
self.$snackbar.open("There it was an error during the request - refresh page and try again");
});
},
goto: function (url) {
window.location.href = url;
}
} }
);
},
deletestudy: function(id){
this.loading = true;
this.message = "";
let self = this;
axios.delete('studies/'+id,{data: id})
.then(response => {
setTimeout(function(){
self.loading = false;
self.$snackbar.open("Study deleted");
window.location.href = '../mesort';
},500);
}).catch(function (error) {
console.log(error);
self.loading = false;
self.$snackbar.open("There it was an error during the request - refresh page and try again");
});
},
goto: function(url){
window.location.href = url;
}
}
}); });
window.app = new Vue({ window.app = new Vue({
el: '#app', el: '#app',
components: { components: {
...@@ -146,9 +141,7 @@ window.app = new Vue({ ...@@ -146,9 +141,7 @@ window.app = new Vue({
Pencil Pencil
}, },
data: { data: {
newstudy: { newstudy: {},
},
users: {}, users: {},
newuser: { newuser: {
showmodal: false, showmodal: false,
...@@ -165,53 +158,58 @@ window.app = new Vue({ ...@@ -165,53 +158,58 @@ window.app = new Vue({
}, },
events: { events: {
'showmodalparent': function(){ 'showmodalparent': function () {
console.log("test") console.log("test")
} }
}, },
methods: { methods: {
showmodal: function(id = null, study){ showmodal: function (id = null, study) {
this.newuser.showmodal = !this.newuser.showmodal; this.newuser.showmodal = !this.newuser.showmodal;
this.newuser.edituser = id; this.newuser.edituser = id;
this.newuser.study = study; this.newuser.study = study;
// if(this.$refs.usertable) this.$refs.usertable.realodtable(); // if(this.$refs.usertable) this.$refs.usertable.realodtable();
}, },
confirmgohome: function() { confirmgohome: function () {
this.$dialog.confirm({ this.$dialog.confirm({
title: 'Cancel interview', title: 'Cancel interview',
message: 'Do you want to cancel this interview?', message: 'Do you want to cancel this interview?',
confirmText: 'go', confirmText: 'go',
type: 'is-danger', type: 'is-danger',
hasIcon: true, hasIcon: true,
onConfirm: () => {window.location.href = '../';} onConfirm: () => {
}) window.location.href = '../';
}, }
setinterviewdname: function(studyid) { })
},
this.$dialog.prompt({ setinterviewdname: function (studyid) {
message: `What's the interviewed name?`,
inputAttrs: { this.$dialog.prompt({
placeholder: '', message: `What's the interviewed name?`,
maxlength: 20, inputAttrs: {
required: false placeholder: '',
maxlength: 20,
}, required: false
onConfirm: (value) => {
if(value.length == 0){console.log("test")}; },
this.interview.interviewed = value; onConfirm: (value) => {
window.location.href = 'interviews/new?study='+studyid+'&interviewed='+value; if (value.length == 0) {
} console.log("test")
}) }
}, ;
reloadusers: function (r) { this.interview.interviewed = value;
window.location.href = 'interviews/new?study=' + studyid + '&interviewed=' + value;
}
})
},
reloadusers: function (r) {
this.users[r[1]] = r[0]; this.users[r[1]] = r[0];
this.$forceUpdate(); this.$forceUpdate();
}, },
showtoast: function(message){ showtoast: function (message) {
window.app.$snackbar.open(message); window.app.$snackbar.open(message);
}
} }
}
}); });
...@@ -122,11 +122,6 @@ ...@@ -122,11 +122,6 @@
</template> </template>
<script> <script>
$(document).on('keydown', function (e) {
if ((e.keyCode == 13)) {
e.preventDefault();
}
});
...@@ -208,6 +203,13 @@ ...@@ -208,6 +203,13 @@
} }
}, },
mounted() { mounted() {
$(document).on('keydown', function (e) {</