Commit 4d6878ba authored by ZeMKI's avatar ZeMKI
Browse files

vuejs optimization + new font + breadcrumb

* Delete some not used components.
* new breadcrumb system.
parent 7974ef56
......@@ -28,6 +28,7 @@ class HomeController extends Controller
{
$data['studies'] = Auth::user()->studies()->with('sortings')->get();
$data['invited_studies'] = Auth::user()->invites;
$data['breadcrumb'] = ['Home'];
if (auth()->user()->profile()->exists())
{
$data['newsletter'] = Auth::user()->profile->newsletter === config('enums.newsletter_status.NOT DECIDED');
......
......@@ -31,6 +31,7 @@ class InterviewController extends Controller
public function show(Interview $interview)
{
$this->authorize($interview);
$data['breadcrumb'] = ['Home','Study',$interview->study->name,$interview->interviewed == __("Name not provided") ? "Interview id ".$interview->id : __("Interview of")." ".$interview->interviewed];
$data['interview'] = $interview;
$data['screenshots'] = [];
$data['sortingtoken'] = $interview->tokens;
......
......@@ -39,6 +39,7 @@ class StudyController extends Controller
$data['interviews'] = $study->interviews()->get();
$data['invites'] = $study->invited;
$data['breadcrumb'] = ['Home','Studies',$study->name];
$data['publicInterviews'] = collect(DB::select('
select study_interview_public_url.id,
art_urls.id as url_id,
......@@ -74,6 +75,8 @@ class StudyController extends Controller
auth()->user()->addAction('Trying to create a study', $request->url(), 'Max numbers of studies reached for user ' . auth()->user()->email);
abort(403, __('You reached the max number of studies'));
}
$data['breadcrumb'] = ['Home','New Study'];
// if(!Auth::user()->cancreatestudies())abort(403,'You cannot create studies');
$data['isedit'] = 'false';
$data['presetimages'] = Helper::getPresetImages();
......@@ -280,6 +283,8 @@ class StudyController extends Controller
public function edit(Study $study)
{
$this->authorize($study);
$data['breadcrumb'] = ['Home','Edit Study'];
$data['study'] = $study;
$data['study']['tokens'] = $study->available_tokens;
$data['study']['sorting'] = $study->sortings;
......
/*!
* Bootstrap v3.3.7 (http://getbootstrap.com)
* Copyright 2011-2018 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
*/
/*!
* Generated using the Bootstrap Customizer (<none>)
* Config saved to config.json and <none>
*/
if("undefined"==typeof jQuery)throw new Error("Bootstrap's JavaScript requires jQuery");+function(t){"use strict";var e=t.fn.jquery.split(" ")[0].split(".");if(e[0]<2&&e[1]<9||1==e[0]&&9==e[1]&&e[2]<1||e[0]>3)throw new Error("Bootstrap's JavaScript requires jQuery version 1.9.1 or higher, but lower than version 4")}(jQuery),+function(t){"use strict";function e(e){return this.each(function(){var i=t(this),n=i.data("bs.tooltip"),s="object"==typeof e&&e;!n&&/destroy|hide/.test(e)||(n||i.data("bs.tooltip",n=new o(this,s)),"string"==typeof e&&n[e]())})}var o=function(t,e){this.type=null,this.options=null,this.enabled=null,this.timeout=null,this.hoverState=null,this.$element=null,this.inState=null,this.init("tooltip",t,e)};o.VERSION="3.3.7",o.TRANSITION_DURATION=150,o.DEFAULTS={animation:!0,placement:"top",selector:!1,template:'<div class="tooltip" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>',trigger:"hover focus",title:"",delay:0,html:!1,container:!1,viewport:{selector:"body",padding:0}},o.prototype.init=function(e,o,i){if(this.enabled=!0,this.type=e,this.$element=t(o),this.options=this.getOptions(i),this.$viewport=this.options.viewport&&t(t.isFunction(this.options.viewport)?this.options.viewport.call(this,this.$element):this.options.viewport.selector||this.options.viewport),this.inState={click:!1,hover:!1,focus:!1},this.$element[0]instanceof document.constructor&&!this.options.selector)throw new Error("`selector` option must be specified when initializing "+this.type+" on the window.document object!");for(var n=this.options.trigger.split(" "),s=n.length;s--;){var r=n[s];if("click"==r)this.$element.on("click."+this.type,this.options.selector,t.proxy(this.toggle,this));else if("manual"!=r){var p="hover"==r?"mouseenter":"focusin",l="hover"==r?"mouseleave":"focusout";this.$element.on(p+"."+this.type,this.options.selector,t.proxy(this.enter,this)),this.$element.on(l+"."+this.type,this.options.selector,t.proxy(this.leave,this))}}this.options.selector?this._options=t.extend({},this.options,{trigger:"manual",selector:""}):this.fixTitle()},o.prototype.getDefaults=function(){return o.DEFAULTS},o.prototype.getOptions=function(e){return e=t.extend({},this.getDefaults(),this.$element.data(),e),e.delay&&"number"==typeof e.delay&&(e.delay={show:e.delay,hide:e.delay}),e},o.prototype.getDelegateOptions=function(){var e={},o=this.getDefaults();return this._options&&t.each(this._options,function(t,i){o[t]!=i&&(e[t]=i)}),e},o.prototype.enter=function(e){var o=e instanceof this.constructor?e:t(e.currentTarget).data("bs."+this.type);return o||(o=new this.constructor(e.currentTarget,this.getDelegateOptions()),t(e.currentTarget).data("bs."+this.type,o)),e instanceof t.Event&&(o.inState["focusin"==e.type?"focus":"hover"]=!0),o.tip().hasClass("in")||"in"==o.hoverState?void(o.hoverState="in"):(clearTimeout(o.timeout),o.hoverState="in",o.options.delay&&o.options.delay.show?void(o.timeout=setTimeout(function(){"in"==o.hoverState&&o.show()},o.options.delay.show)):o.show())},o.prototype.isInStateTrue=function(){for(var t in this.inState)if(this.inState[t])return!0;return!1},o.prototype.leave=function(e){var o=e instanceof this.constructor?e:t(e.currentTarget).data("bs."+this.type);return o||(o=new this.constructor(e.currentTarget,this.getDelegateOptions()),t(e.currentTarget).data("bs."+this.type,o)),e instanceof t.Event&&(o.inState["focusout"==e.type?"focus":"hover"]=!1),o.isInStateTrue()?void 0:(clearTimeout(o.timeout),o.hoverState="out",o.options.delay&&o.options.delay.hide?void(o.timeout=setTimeout(function(){"out"==o.hoverState&&o.hide()},o.options.delay.hide)):o.hide())},o.prototype.show=function(){var e=t.Event("show.bs."+this.type);if(this.hasContent()&&this.enabled){this.$element.trigger(e);var i=t.contains(this.$element[0].ownerDocument.documentElement,this.$element[0]);if(e.isDefaultPrevented()||!i)return;var n=this,s=this.tip(),r=this.getUID(this.type);this.setContent(),s.attr("id",r),this.$element.attr("aria-describedby",r),this.options.animation&&s.addClass("fade");var p="function"==typeof this.options.placement?this.options.placement.call(this,s[0],this.$element[0]):this.options.placement,l=/\s?auto?\s?/i,a=l.test(p);a&&(p=p.replace(l,"")||"top"),s.detach().css({top:0,left:0,display:"block"}).addClass(p).data("bs."+this.type,this),this.options.container?s.appendTo(this.options.container):s.insertAfter(this.$element),this.$element.trigger("inserted.bs."+this.type);var h=this.getPosition(),f=s[0].offsetWidth,c=s[0].offsetHeight;if(a){var u=p,d=this.getPosition(this.$viewport);p="bottom"==p&&h.bottom+c>d.bottom?"top":"top"==p&&h.top-c<d.top?"bottom":"right"==p&&h.right+f>d.width?"left":"left"==p&&h.left-f<d.left?"right":p,s.removeClass(u).addClass(p)}var v=this.getCalculatedOffset(p,h,f,c);this.applyPlacement(v,p);var g=function(){var t=n.hoverState;n.$element.trigger("shown.bs."+n.type),n.hoverState=null,"out"==t&&n.leave(n)};t.support.transition&&this.$tip.hasClass("fade")?s.one("bsTransitionEnd",g).emulateTransitionEnd(o.TRANSITION_DURATION):g()}},o.prototype.applyPlacement=function(e,o){var i=this.tip(),n=i[0].offsetWidth,s=i[0].offsetHeight,r=parseInt(i.css("margin-top"),10),p=parseInt(i.css("margin-left"),10);isNaN(r)&&(r=0),isNaN(p)&&(p=0),e.top+=r,e.left+=p,t.offset.setOffset(i[0],t.extend({using:function(t){i.css({top:Math.round(t.top),left:Math.round(t.left)})}},e),0),i.addClass("in");var l=i[0].offsetWidth,a=i[0].offsetHeight;"top"==o&&a!=s&&(e.top=e.top+s-a);var h=this.getViewportAdjustedDelta(o,e,l,a);h.left?e.left+=h.left:e.top+=h.top;var f=/top|bottom/.test(o),c=f?2*h.left-n+l:2*h.top-s+a,u=f?"offsetWidth":"offsetHeight";i.offset(e),this.replaceArrow(c,i[0][u],f)},o.prototype.replaceArrow=function(t,e,o){this.arrow().css(o?"left":"top",50*(1-t/e)+"%").css(o?"top":"left","")},o.prototype.setContent=function(){var t=this.tip(),e=this.getTitle();t.find(".tooltip-inner")[this.options.html?"html":"text"](e),t.removeClass("fade in top bottom left right")},o.prototype.hide=function(e){function i(){"in"!=n.hoverState&&s.detach(),n.$element&&n.$element.removeAttr("aria-describedby").trigger("hidden.bs."+n.type),e&&e()}var n=this,s=t(this.$tip),r=t.Event("hide.bs."+this.type);return this.$element.trigger(r),r.isDefaultPrevented()?void 0:(s.removeClass("in"),t.support.transition&&s.hasClass("fade")?s.one("bsTransitionEnd",i).emulateTransitionEnd(o.TRANSITION_DURATION):i(),this.hoverState=null,this)},o.prototype.fixTitle=function(){var t=this.$element;(t.attr("title")||"string"!=typeof t.attr("data-original-title"))&&t.attr("data-original-title",t.attr("title")||"").attr("title","")},o.prototype.hasContent=function(){return this.getTitle()},o.prototype.getPosition=function(e){e=e||this.$element;var o=e[0],i="BODY"==o.tagName,n=o.getBoundingClientRect();null==n.width&&(n=t.extend({},n,{width:n.right-n.left,height:n.bottom-n.top}));var s=window.SVGElement&&o instanceof window.SVGElement,r=i?{top:0,left:0}:s?null:e.offset(),p={scroll:i?document.documentElement.scrollTop||document.body.scrollTop:e.scrollTop()},l=i?{width:t(window).width(),height:t(window).height()}:null;return t.extend({},n,p,l,r)},o.prototype.getCalculatedOffset=function(t,e,o,i){return"bottom"==t?{top:e.top+e.height,left:e.left+e.width/2-o/2}:"top"==t?{top:e.top-i,left:e.left+e.width/2-o/2}:"left"==t?{top:e.top+e.height/2-i/2,left:e.left-o}:{top:e.top+e.height/2-i/2,left:e.left+e.width}},o.prototype.getViewportAdjustedDelta=function(t,e,o,i){var n={top:0,left:0};if(!this.$viewport)return n;var s=this.options.viewport&&this.options.viewport.padding||0,r=this.getPosition(this.$viewport);if(/right|left/.test(t)){var p=e.top-s-r.scroll,l=e.top+s-r.scroll+i;p<r.top?n.top=r.top-p:l>r.top+r.height&&(n.top=r.top+r.height-l)}else{var a=e.left-s,h=e.left+s+o;a<r.left?n.left=r.left-a:h>r.right&&(n.left=r.left+r.width-h)}return n},o.prototype.getTitle=function(){var t,e=this.$element,o=this.options;return t=e.attr("data-original-title")||("function"==typeof o.title?o.title.call(e[0]):o.title)},o.prototype.getUID=function(t){do t+=~~(1e6*Math.random());while(document.getElementById(t));return t},o.prototype.tip=function(){if(!this.$tip&&(this.$tip=t(this.options.template),1!=this.$tip.length))throw new Error(this.type+" `template` option must consist of exactly 1 top-level element!");return this.$tip},o.prototype.arrow=function(){return this.$arrow=this.$arrow||this.tip().find(".tooltip-arrow")},o.prototype.enable=function(){this.enabled=!0},o.prototype.disable=function(){this.enabled=!1},o.prototype.toggleEnabled=function(){this.enabled=!this.enabled},o.prototype.toggle=function(e){var o=this;e&&(o=t(e.currentTarget).data("bs."+this.type),o||(o=new this.constructor(e.currentTarget,this.getDelegateOptions()),t(e.currentTarget).data("bs."+this.type,o))),e?(o.inState.click=!o.inState.click,o.isInStateTrue()?o.enter(o):o.leave(o)):o.tip().hasClass("in")?o.leave(o):o.enter(o)},o.prototype.destroy=function(){var t=this;clearTimeout(this.timeout),this.hide(function(){t.$element.off("."+t.type).removeData("bs."+t.type),t.$tip&&t.$tip.detach(),t.$tip=null,t.$arrow=null,t.$viewport=null,t.$element=null})};var i=t.fn.tooltip;t.fn.tooltip=e,t.fn.tooltip.Constructor=o,t.fn.tooltip.noConflict=function(){return t.fn.tooltip=i,this}}(jQuery),+function(t){"use strict";function e(e){return this.each(function(){var i=t(this),n=i.data("bs.popover"),s="object"==typeof e&&e;!n&&/destroy|hide/.test(e)||(n||i.data("bs.popover",n=new o(this,s)),"string"==typeof e&&n[e]())})}var o=function(t,e){this.init("popover",t,e)};if(!t.fn.tooltip)throw new Error("Popover requires tooltip.js");o.VERSION="3.3.7",o.DEFAULTS=t.extend({},t.fn.tooltip.Constructor.DEFAULTS,{placement:"right",trigger:"click",content:"",template:'<div class="popover" role="tooltip"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>'}),o.prototype=t.extend({},t.fn.tooltip.Constructor.prototype),o.prototype.constructor=o,o.prototype.getDefaults=function(){return o.DEFAULTS},o.prototype.setContent=function(){var t=this.tip(),e=this.getTitle(),o=this.getContent();t.find(".popover-title")[this.options.html?"html":"text"](e),t.find(".popover-content").children().detach().end()[this.options.html?"string"==typeof o?"html":"append":"text"](o),t.removeClass("fade top bottom left right in"),t.find(".popover-title").html()||t.find(".popover-title").hide()},o.prototype.hasContent=function(){return this.getTitle()||this.getContent()},o.prototype.getContent=function(){var t=this.$element,e=this.options;return t.attr("data-content")||("function"==typeof e.content?e.content.call(t[0]):e.content)},o.prototype.arrow=function(){return this.$arrow=this.$arrow||this.tip().find(".arrow")};var i=t.fn.popover;t.fn.popover=e,t.fn.popover.Constructor=o,t.fn.popover.noConflict=function(){return t.fn.popover=i,this}}(jQuery);
\ No newline at end of file
......@@ -39,12 +39,6 @@ Vue.component(
require(
'./components/Interview/sorting_preview.vue').default,
);
Vue.component(
'userpart',
require(
'./components/userpart.vue').default,
);
Vue.component(
'url-list',
require(
......@@ -55,11 +49,6 @@ Vue.component(
require(
'./components/newstudy.vue').default,
);
Vue.component(
'new-edit-user',
require(
'./components/modalnewedituser.vue').default,
);
Vue.component(
'action-table',
require(
......
<template>
<div v-if="showmodal" :class="showmodal ? 'is-active modaluser modal' : 'modal modaluser'">
<div class="modal-background"></div>
<div class="modal-card">
<header class="modal-card-head">
<p class="modal-card-title">{{ trans('Add/edit User for study') }} {{study}}</p>
</header>
<section class="modal-card-body">
<div class="columns">
<div class="level">
<div class="column is-four-fifths">
<div class="field">
<label class="label">{{ trans('Email') }} </label>
<div class="control">
<input class="input has-background-dark has-text-light" type="email"
placeholder="User email" id="studyname" v-model="email"/>
</div>
<span v-if="emailexistmessage.length > 0"
:class="this.emailexist ? 'tag is-warning' : 'tag is-danger'"
v-html="emailexistmessage"></span>
</div>
</div>
<div class="column is-one-fourth">
<div class="field">
<b-field label="User Role">
<b-select placeholder="Select a role" v-model="userroleselected">
<option
v-for="role in inputs.userroles"
:value="role.value"
:key="role.value">
{{ role.name }}
</option>
</b-select>
</b-field>
</div>
</div>
<div class="column is-one-fourth" v-if="this.update">
<div class="field">
<label class="label"> {{ trans('Reset') }} </label>
<a class="button is-danger" @click="sendresetpassworddialog">{{ trans('Send reset email') }}</a>
</div>
</div>
</div>
</div>
<div v-if="errors.length > 0" class="notification is-danger" role="alert">
<p v-if="errors" v-for="(error,index) in errors"> {{error}}</p>
</div>
<div v-if="message" class="notification is-success " role="alert">
{{message}}
</div>
</section>
<footer class="modal-card-foot">
<button v-if="!update" class="button is-success" @click="saveuser">{{ trans('Save changes') }}</button>
<button v-if="update" class="button is-success" @click="updateuser">Update User</button>
<button class="button" @click="showmodalparent">{{ trans('Cancel') }}</button>
</footer>
</div>
</div>
</template>
<script>
export default {
props: ['showmodal', 'assignstudy', 'edituser', 'study'],
mounted() {
},
data() {
return {
email: "",
emailexist: false,
emailexistmessage: "",
studyradio: 0,
userroleselected: [],
previouspermissions: {},
studiesselected: [],
supervisorselected: [],
allpermissions: [],
globalpermissions: {
cancreateusers: false,
cancreatestudy: false
},
inputs: {
userroles: [],
studies: [],
supervisors: []
},
errors: [],
message: "",
usertoedit: {}
}
},
computed: {
update: function () {
return (this.edituser > 0);
}
},
watch: {
showmodal: function (newVal, oldVal) {
let self = this;
self.message = "";
self.errors = [];
// from edit to add new
if (!this.update) {
this.usertoedit = {};
this.emptyform();
}
if (newVal) {
// for some reasons it can't find the modal background
// but after 1 millisecond it does
setTimeout(function () {
document.querySelector('.modal-background').addEventListener('click', function (e) {
document.querySelector('html').classList.remove('is-clipped');
self.$emit('showmodalparent');
});
}, 1);
this.getinputdata();
}
},
'permissions.onlyconsult': function (newVal, oldVal) {
let self = this;
if (newVal) {
self.permissions.caneditstudy = false;
self.permissions.canassignusers = false;
}
},
permissions: {
deep: true,
handler(val) {
let self = this;
console.log(val)
let permissionsVariables = {
1: "onlyconsult",
2: "caneditstudy",
3: "canassignusers",
4: "cancreateusers",
5: "cancreatestudy",
6: "creator"
};
for (var permission in val) {
self.studiesselected[self.studyradio][permission] = val[permission];
}
}
},
userroleselected: function (newVal, oldVal) {
let self = this;
if (newVal == 2) {
self.globalpermissions.cancreatestudy = true;
self.globalpermissions.cancreateusers = true;
} else if (newVal == 3) {
self.resetallpermissions();
}
},
email: function (newVal, oldVal) {
if (newVal.length > 4 && newVal.indexOf('@') > -1 && !this.update) {
var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
if (re.test(String(newVal).toLowerCase())) {
window.axios.post('checkemail', {email: newVal}).then(response => {
this.emailexist = response.data;
if (response.data) {
this.emailexistmessage = "This user will be invited.";
} else {
this.emailexistmessage = "This user is not registered, an invitation email will be sent.";
}
}).catch(error => {
});
} else {
}
}
}
},
methods: {
createStudyPermissionArray: function (id) {
let permissionsVariables = [
"onlyconsult",
"caneditstudy",
"canassignusers"
];
/// if the study doesn't exist, initialize with all false values
/// otherwise assign the values to the 3 permissions checkboxes
if (_.isUndefined(this.studiesselected[id])) {
this.studiesselected[id] = {}
for (var i = 0; i < permissionsVariables.length; i++) {
this.studiesselected[id][permissionsVariables[i]] = false;
}
this.resetspecificpermissions();
} else {
console.log("study exist")
for (let p in this.permissions) {
this.permissions[p] = this.studiesselected[id][p];
}
}
},
getinputdata: function () {
this.inputs.supervisors = [];
window.axios.post('getinputdata').then(response => {
this.inputs.userroles = response.data.allroles;
this.userroleselected = 2;
}).catch(error => {
console.log("error " + error);
});
},
showmodalparent: function () {
this.$emit('showmodalparent');
},
saveuser: function () {
let activeStudies = this.study;
if (this.validate()) {
let user = {};
_.merge(user, {email: this.email}, {emailexist: this.emailexist}, {role: this.userroleselected}, {study: activeStudies});
window.axios.post('users', user).then(response => {
this.message = "";
this.message = response.data;
window.axios.get('studies/users/' + this.study).then(response => {
// this.$emit('reloadusers',{'response':response,'study': this.study});
Vue.set(this.$parent.users, this.study, response.data)
// this.$parent.$forceUpdate();
}).catch(error => {
console.log(error);
});
}).catch(error => {
this.errors = error.message;
});
}
},
updateuser: function () {
let user = {};
_.merge(user, {id: this.usertoedit}, {email: this.email}, {emailexist: this.emailexist}, {roles: this.userroleselected}, {studies: this.studiesselected}, {permissions: this.permissions});
window.axios.post('updateuser', user).then(response => {
this.message = "";
this.message = response.data;
}).catch(error => {
this.errors = error.data;
});
},
validate: function () {
this.errors = [];
if (this.email == "" || !this.validEmail) this.errors.push("please enter a valid email");
if (!this.userroleselected) this.errors.push("please select a role");
if (this.errors.length > 0) return false;
else return true;
},
validEmail: function () {
var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return re.test(this.email);
},
emptyform: function () {
this.email = "";
this.emailexistmessage = "";
this.userroleselected = [];
this.studiesselected = [];
},
sendresetpassworddialog() {
this.$dialog.confirm({
title: 'Send reset password email',
message: 'Are you sure you want to <b>reset</b> password and wait for the user to set it? This action cannot be undone.',
confirmText: 'Send',
type: 'is-danger',
hasIcon: true,
onConfirm: () => this.sendresetopassword()
})
},
sendresetopassword() {
window.axios.post('resetpassword', this.usertoedit).then(response => {
this.message = "";
this.message = response.data;
}).catch(error => {
this.errors = error.data.errors;
});
},
resetallpermissions: function () {
this.globalpermissions.cancreateusers = false;
this.globalpermissions.cancreatestudy = false;
}
}
}
</script>
<template>
<section>
<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-left" @click="confirmDeleteUser(user)">
<b-icon icon="delete-sweep" class="has-text-danger "></b-icon>
</div>
<div class="level-right">{{user['email']}}</div>
</div>
<div class="columns is-multiline">
<div class="column" v-for="role in user['roles']">
<span class="tag is-primary" v-if="role.pivot.study_id == study">{{role['name']}}</span>
</div>
</div>
</div>
<a class="button is-light" id="open-user-modal" style="width: 100%; display: inline-flex;"
@click="$emit('parentshowmodal')">Add user</a>
</section>
</template>
<script>
export default {
props: ['usersinstudy', 'study', 'auth', 'studyeditable'],
data() {
return {
caneditthisstudy: {},
cancreatestudies: {}
}
}
, created() {
let self = this;
for (var i = 0; i < this.usersinstudy.length; i++) {
this.caneditthisstudy[this.usersinstudy[i]['id']] = (this.isItemInArray(this.usersinstudy[i]['permissions'].map((el) => [el.id, el.pivot.study_id]), [15, this.study]) ? true : false);
}
for (var i = 0; i < this.usersinstudy.length; i++) {
this.cancreatestudies[this.usersinstudy[i]['id']] = (this.usersinstudy[i]['permissions'].map((el) => el.id).indexOf(13) > -1 ? true : false);
}
},
methods: {
confirmDeleteUser: function (user) {
window.app.$buefy.dialog.confirm({
title: 'Delete User',
message: 'Do you want to delete this user? ' + user.email,
confirmText: 'Delete',
type: 'is-danger',
hasIcon: true,
onConfirm: () => this.deleteUser(user)
})
},
confirmSendConfirmationEmail: function (user) {
window.app.$buefy.dialog.confirm({
title: 'Reset User Password',
message: 'Do you want to send again the confirmation email to this user? ' + user.email,
confirmText: 'Resend',
type: 'is-warning',
hasIcon: true,
onConfirm: () => this.confirmUser(user)
})
},
confirmUser: function (user) {
window.axios.patch('usersconfirm/' + user.id).then(response => {
window.app.$buefy.snackbar.open("User needs to create a new password");
}).catch(error => {
})
},
deleteUser: function (user) {
window.axios.post('users/' + user.id + '/' + this.study).then(response => {
window.app.$buefy.snackbar.open("User deleted");
window.axios.get('studies/users/' + this.study).then(response => {
Vue.set(window.app.users, this.study, response.data)
}).catch(error => {
});
}).catch(error => {
})
},
changeEditPermission: function (value, user) {
let valueToSend = {'value': value}
window.axios.post('users/' + user + '/canedit/' + this.study, valueToSend).then(response => {
window.app.$buefy.snackbar.open("Permission changed.");
}).catch(error => {
})
},
changestudiespermission: function (value, user) {
let valueToSend = {'value': value}
window.axios.patch('userscanedit/' + user['id'], valueToSend).then(response => {
if (value) {
window.app.$buefy.snackbar.open(user['email'] + ' can now create studies.');
} else {
window.app.$buefy.snackbar.open(user['email'] + ' cannot create studies.');
}
}).catch(error => {
})
},