Commit 36156356 authored by ZeMKI's avatar ZeMKI
Browse files

Edit study

* done the edit study (consider more testing)
* layout optimization
parent bacb1866
......@@ -1383,7 +1383,6 @@ export default {
author: '', editable: false,
fetching: false,
selectedSorting: 1,
qsortselected: false,
sorting: {
id: 1,
qsortshownumbers: true,
......@@ -1432,6 +1431,7 @@ export default {
};
}, computed: {
'qsortElements': function () {
let totalLength = 0;
this.sorting.qsort.forEach(function (element) {
totalLength = totalLength + element.length - 2;
......@@ -1441,12 +1441,10 @@ export default {
setTimeout(() => {
let direction = (totalLength - self.sorting.tokennumber);
if (direction > 0) {
for (var i = 0;
for (let i = 0;
i < direction;
i++) {
console.log('more tokeeens!');
self.sorting.tokennumber++;
}
}
......@@ -1456,17 +1454,19 @@ export default {
}
else {
// decrease
for (var i = 0;
for (let i = 0;
i < Math.abs(direction);
i++) {
self.sorting.tokennumber--;
}
}
}, 500);
}, 50);
return totalLength;
}, 'sortingname': function () {
if (this.sorting.id === 1) {
this.trans('Circle Sorting');
......@@ -1530,7 +1530,7 @@ export default {
let direction = (newVal - oldVal);
if (direction > 0) {
for (var i = 0;
for (let i = 0;
i < direction;
i++) {
this.sorting.sections.push({
......@@ -1540,7 +1540,7 @@ export default {
}
else {
// decrease
for (var i = 0;
for (let i = 0;
i < Math.abs(direction);
i++) {
this.sorting.sections.pop();
......@@ -1556,7 +1556,7 @@ export default {
let direction = (newVal - oldVal);
if (direction > 0) {
for (var i = 0;
for (let i = 0;
i < direction;
i++) {
let questiontemplate = {
......@@ -1571,7 +1571,7 @@ export default {
}
else {
// decrease
for (var i = 0;
for (let i = 0;
i < Math.abs(direction);
i++) {
this.presort.questions.pop();
......@@ -1591,7 +1591,7 @@ export default {
let direction = (newVal - oldVal);
if (direction > 0) {
for (var i = 0;
for (let i = 0;
i < direction;
i++) {
let questiontemplate = {
......@@ -1606,7 +1606,7 @@ export default {
}
else {
// decrease
for (var i = 0;
for (let i = 0;
i < Math.abs(direction);
i++) {
this.postsort.questions.pop();
......@@ -1623,7 +1623,7 @@ export default {
let direction = (newVal - oldVal);
if (direction > 0) {
for (var i = 0;
for (let i = 0;
i < direction;
i++) {
this.sorting.qsort.push(['', '']);
......@@ -1635,7 +1635,7 @@ export default {
}
else {
// decrease
for (var i = 0;
for (let i = 0;
i < Math.abs(direction);
i++) {
this.sorting.qsort.pop();
......@@ -1655,7 +1655,7 @@ export default {
if (direction > 0) {
for (var i = 0;
for (let i = 0;
i < direction;
i++) {
let tokentemplate = {
......@@ -1671,7 +1671,7 @@ export default {
}
else {
// decrease
for (var i = 0;
for (let i = 0;
i < Math.abs(direction);
i++) {
this.sorting.tokens.pop();
......@@ -1704,7 +1704,6 @@ export default {
function substrInBetween(whole_str, str1, str2) {
return whole_str.substring(whole_str.indexOf(str1) + str1.length, whole_str.lastIndexOf(str2));
}
this.fetching = true;
......@@ -1758,33 +1757,52 @@ export default {
let self = this;
this.sorting.tokennumber = this.studydata.tokens.length;
for (var i = 0;
i < this.studydata.tokens.length;
i++) {
this.sorting.tokens[i] = this.studydata.tokens[i];
if (_.has(this.sorting.tokens[i], 'image_path') && this.sorting.tokens[i].image_path.indexOf('presets') == -1) {
this.sorting.tokens[i].base64 = this.sorting.tokens[i].image_path;
if (self.studydata.sorting[0].id === 3) {
let qsort = this.studydata.sortings[0].pivot.details.substr(this.studydata.sortings[0].pivot.details.indexOf('qsort|') + 6).split('|separator|');
qsort.pop();
let qsortArray = [];
_.forEach(qsort, function (value, key) {
qsortArray.push(value.split('|'));
});
this.sorting.qsortNumber = qsortArray.length;
this.sorting.qsort = qsortArray;
for (let i = 0;
i < self.qsortElements;
i++) {
self.sorting.tokens[i] = self.studydata.tokens[i];
self.sorting.tokens[i].properties = JSON.parse(self.sorting.tokens[i].properties);
if (_.has(self.sorting.tokens[i], 'image_path') && self.sorting.tokens[i].image_path.indexOf('presets') == -1) {
self.sorting.tokens[i].base64 = self.sorting.tokens[i].image_path;
}
}
}
for (var i = 0;
i < this.studydata.tokens.length;
i++) {
}else{
for (let i = 0;
i < this.studydata.tokens.length;
i++) {
this.sorting.tokens[i] = this.studydata.tokens[i];
if (_.has(this.sorting.tokens[i], 'image_path') && this.sorting.tokens[i].image_path.indexOf('presets') == -1) {
this.sorting.tokens[i].base64 = this.sorting.tokens[i].image_path;
}
}
}
setTimeout(function () {
//if(self.sorting.tokennumber > 1) self.sorting.tokens.pop();
for (var i = 0;
for (let i = 0;
i < self.studydata.tokens.length;
i++) {
document.querySelector('#token' + i).src = self.studydata.tokens[i].image_path;
}
for (var i = 0;
for (let i = 0;
i < self.presort.number;
i++) {
......@@ -1847,7 +1865,7 @@ export default {
}
for (var i = 0;
for (let i = 0;
i < self.postsort.number;
i++) {
self.postsort.questions[i].question = self.studydata.q.postsort[i].question;
......@@ -1905,6 +1923,8 @@ export default {
});
}
self.fetching = false;
}, 100);
}, savestudy: function () {
......@@ -1912,9 +1932,9 @@ export default {
if (this.validdata()) {
let study = {};
this.loading = true;
if(this.selectedSorting == 3){
if (this.selectedSorting == 3) {
let qsortbasenumbers = document.getElementsByClassName("qsortbasenumbers");
_.forEach(this.sorting.qsort, (q,key) => {
_.forEach(this.sorting.qsort, (q, key) => {
q[1] = qsortbasenumbers[key].innerText;
});
}
......@@ -1956,6 +1976,13 @@ export default {
}
if (this.selectedSorting == 3) {
let qsortbasenumbers = document.getElementsByClassName("qsortbasenumbers");
_.forEach(this.sorting.qsort, (q, key) => {
q[1] = qsortbasenumbers[key].innerText;
});
}
_.merge(study, {id: this.studydata.id}, {name: this.name}, {author: this.author}, {description: this.short_description}, {sorting: this.sorting}, {presort: this.presort}, {postsort: this.postsort});
window.axios.patch(window.location.origin + this.productionUrl + '/studies/' + study['id'], study).then(response => {
......@@ -2143,7 +2170,7 @@ export default {
let im = new Image();
im.onload = function () {
var canvas = document.createElement('canvas'), ctx = canvas.getContext('2d');
let canvas = document.createElement('canvas'), ctx = canvas.getContext('2d');
canvas.width = 100;
canvas.height = 100;
if (im.width < 100 || im.height < 100) {
......@@ -2164,7 +2191,6 @@ export default {
reader.readAsDataURL(file);
if (this.sorting.tokens[index].file === '') {
console.log('wattafuck');
self.sorting.tokens[index].base64 = '';
document.getElementById('token' + index).src = '';
......@@ -2222,7 +2248,7 @@ export default {
let count = this[detail].questions[index].answers.length - _.parseInt(this[detail].questions[index].numberofanswer);
if (count > 0) {
for (var i = 0;
for (let i = 0;
i < count;
i++) {
this[detail].questions[index].answers.pop();
......@@ -2230,10 +2256,8 @@ export default {
}
}, setTokenFromPreset: function (index) {
console.log('in set token from preset');
console.log(this.sorting.tokens[index].file);
if (!this.fetching && this.sorting.tokens[index].file !== '') {
var url = this.sorting.tokens[index].file;
let url = this.sorting.tokens[index].file;
this.image = '';
window.axios({
method: 'get', url: url, responseType: 'arraybuffer', headers: {
......@@ -2247,7 +2271,7 @@ export default {
im.src = base64;
let self = this;
im.onload = function () {
var canvas = document.createElement('canvas'), ctx = canvas.getContext('2d');
let canvas = document.createElement('canvas'), ctx = canvas.getContext('2d');
canvas.width = 100;
canvas.height = 100;
if (im.width < 100 || im.height < 100) {
......
......@@ -64,7 +64,7 @@
<!--End Modal-->
@if(count($studies) > 0)
<div class="mx-auto mx-auto w-1/2 my-4">
<div class="mx-auto w-2/3 my-4">
<h1 class="text-4xl font-extrabold text-blue-600 break-words">Your Studies
<span class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-full @if(count($studies) > 12) text-red-700 @endif">{{count($studies)}} / 15</span>
@if(session('hasReachMaxNumberOfStudies'))
......
<nav class="flex items-center w-screen py-2 justify-between bg-gray-900">
<nav class="flex items-center w-screen py-2 justify-between bg-gray-900 py-4">
<div class="flex items-center text-blue-400 h-full">
<img src="{{config('utilities.base64logo')}}" class="w-10 h-10" alt="Mesort Logo">
<a class="font-bold hover:bg-blue-300 hover:text-white" target="_blank"
href="https://mesoftware.org/index.php/mesort/" title="Mesort Manual"
rel="noopener noreferrer"> {{ __('Mesort Manual') }} </a>
rel="noopener noreferrer"> {{ __('MeSort Manual') }} </a>
<a class="font-semibold ml-4 hover:bg-blue-300 hover:text-white px-4"
<a class="font-semibold ml-4 hover:bg-blue-300 hover:text-white px-4 py-4"
href="{{url('/')}}"
>
{{ __('Home') }}
</a>
@if(Auth::user()->hasRole('admin'))
<a target="_blank" class="font-semibold ml-4 hover:bg-blue-300 hover:text-white px-4"
<a target="_blank" class="font-semibold ml-4 hover:bg-blue-300 hover:text-white px-4 py-4"
href="{{url('translations')}}"
>
{{ __('Translations') }}
......@@ -38,7 +38,7 @@
@if(!session('hasReachMaxNumberOfStudies'))
<a class="font-semibold ml-4 hover:bg-blue-300 hover:text-white px-4 mr-4"
<a class="font-semibold ml-4 hover:bg-blue-300 hover:text-white px-4 mr-4 py-4"
href="{{url('studies/new')}}"
>
......@@ -50,7 +50,7 @@
@endif
@if(Auth::user()->hasRole(['admin']))
<div
class="lg:inline-block languagedropbtn relative inline-block hover:cursor-pointer mr-4 font-semibold hover:bg-blue-300 hover:text-white"
class="lg:inline-block languagedropbtn relative inline-block hover:cursor-pointer mr-4 font-semibold hover:bg-blue-300 hover:text-white py-4"
href="#" @click="showdropdown('dropdownLanguage')" @mouseover="showdropdown('dropdownLanguage')"
>
......@@ -76,7 +76,7 @@
</div>
@endif
<div
class="mt-4 lg:inline-block lg:mt-0 mr-4 logoutdropbtn relative inline-block hover:cursor-pointer flex font-bold"
class="lg:inline-block lg:mt-0 mr-4 logoutdropbtn relative inline-block hover:cursor-pointer flex font-bold py-4"
href="#" @click="showdropdown('dropdownLogout')" @mouseover="showdropdown('dropdownLogout')"
>
{{ Auth::user()->email }}
......
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