Add disabled state for Quiz when filled + More locales in /app

This commit is contained in:
Niko 2022-03-02 00:54:38 +01:00
parent f6b03ee4c8
commit 3519aba243
4 changed files with 27 additions and 7 deletions

View File

@ -93,7 +93,10 @@ img.avatar {
.button.disabled {
filter: grayscale() !important;
filter: grayscale() !important;
cursor: initial !important;
user-select: none;
z-index: -1;
}
.button.floating {
padding: 1.5em;
@ -276,6 +279,7 @@ main {
top: 0;
background: #f9f9f9;
border-bottom: 10px solid #00000014;
z-index: 1;
}
#quiz .person .lovebg {
padding: 1.5em 2em;

View File

@ -71,11 +71,20 @@ app.pages.quiz = {
}
});
content.innerHTML += tpl;
if (item.options.length > 0) {
if (item.options.length > 0)
document.querySelector(`#quiz #question-${i} .type-freetext`).remove();
} else {
document.querySelector(`#quiz #question-${i} .type-options`).remove();
}
else document.querySelector(`#quiz #question-${i} .type-options`).remove();
}
if (json.responses !== undefined && json.responses.length > 0) {
document.querySelectorAll('form label.button')
.forEach(function(item) { item.classList.add('disabled') });
document.querySelectorAll('form input[type="text"], form input[type="radio"]')
.forEach(function(item) { item.setAttribute('disabled', 'true') });
for (var i in json.responses)
document.querySelector('form#quiz')['question_'+i]
.value = json.responses[parseInt(i)];
document.querySelector('*[onclick*="actions.send"]').remove();
}
page().scrollInit();
},
@ -163,11 +172,16 @@ app.pages.quiz = {
const key = 'question_'+page().data.content[i].index;
const value = form[key].value.trim();
if (value === '')
return app.toast.error('TODO: translate: you must fill all quiz questions before sending it');
return app.toast.error(s('app.error.must_fill_quiz'));
data[key] = value;
}
http.post('/api/v1/me/quizs', data, function(json) {
console.log(json);
if (json.error !== undefined)
app.toast.error(app.strings.app.error[json.error]);
else if (json.result === 1) {
app.toast.info(app.strings.app.ok.quiz_sent);
setTimeout(function(){ exit() }, app.toast.DEFAULT_MILLIS);
}
});
},
},

View File

@ -53,6 +53,7 @@ $strings = [
'follow_rejected_max' => 'You have reached the limit of crush requests on this person',
'user_blocked_you' => 'We are sorry, this person rejected to be your crush. You will find another love soon!',
'already_sent_quiz' => 'Sorry, you can\'t send the Quiz again. It was already sent.',
'must_fill_quiz' => 'Error, you must fill all Quiz questions before sending it.',
],
],
];

View File

@ -53,6 +53,7 @@ $strings = [
'follow_rejected_max' => 'Has alcanzado el límite de peticiones de crush para esta persona',
'user_blocked_you' => 'Lo sentimos, esta persona ha rechazado ser su crush. ¡Encontrarás a otra persona pronto!',
'already_sent_quiz' => 'Lo siento, no puedes enviar este Quiz de nuevo. Ya ha sido enviado antes.',
'must_fill_quiz' => 'Error, debes rellenar todas las preguntas del Quiz antes de enviarlo.',
],
],
];