Filling questionnaire process for client now works like a charm

This commit is contained in:
Gregorio Chiko Putra 2018-01-16 15:18:22 +07:00
parent 573f678c69
commit 3f66ec9a4c
10 changed files with 1810 additions and 1429 deletions

32
assets/css/custom/loading.css vendored Normal file
View File

@ -0,0 +1,32 @@
.signal {
border: 3px solid #333;
border-radius: 50px;
height: 50px;
left: 50%;
margin: -25px 0 0 -25px;
opacity: 0;
position: absolute;
top: 50%;
width: 50px;
animation: pulsate 1.2s ease-out;
animation-iteration-count: infinite;
}
.late {
animation-delay: .25s;
}
@keyframes pulsate {
0% {
transform: scale(.1);
opacity: 0.0;
}
50% {
opacity: 1;
}
100% {
transform: scale(1.2);
opacity: 0;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,23 +1,20 @@
import m from "mithril" import m from "mithril"
import { Card, RaisedButton } from "polythene-mithril" import { Card, Button } from "polythene-mithril"
import Questionnaire from "../../models/Questionnaire" import Questionnaire from "../../models/Questionnaire"
import QuestionnaireSection from "../../models/QuestionnaireSection" import QuestionnaireSection from "../../models/QuestionnaireSection"
export const questionnaire = { export const questionnaire = {
oninit: function(vnode) { oninit: function(vnode) {
window.scrollTo(0, 0) Questionnaire.fetch(vnode.attrs.id)
if ( QuestionnaireSection.fetch(vnode.attrs.id)
_.isEmpty(QuestionnaireSection.current)
|| _.isNil(QuestionnaireSection.current)
|| _.isEmpty(Questionnaire.current)
|| _.isNil(Qustionnaire.current)
) {
Questionnaire.fetch(vnode.attrs.id)
QuestionnaireSection.fetch(vnode.attrs.id)
}
}, },
view: function() { oncreate: function(vnode) {
return [ window.scrollTo(0, 0)
},
view: function(vnode) {
return _.isEmpty(Questionnaire.current)
|| _.isEmpty(QuestionnaireSection.current) ?
[m(".signal"), m(".signal.late")] : [
m(".header-img", { m(".header-img", {
style: { style: {
backgroundImage: "url('img/head1.jpg')" backgroundImage: "url('img/head1.jpg')"

4
assets/js/index.js vendored
View File

@ -11,6 +11,7 @@ import { section } from "./components/section"
import { editSection } from "./components/editSection" import { editSection } from "./components/editSection"
import { question } from "./components/question" import { question } from "./components/question"
import clientQuestion from "./components/client/question" import clientQuestion from "./components/client/question"
import clientQuestionRedirect from "./components/client/questionRedirect"
import { editQuestion } from "./components/editQuestion" import { editQuestion } from "./components/editQuestion"
import signup from "./components/hello" import signup from "./components/hello"
import {userList, userAll} from "./components/beta/userList" import {userList, userAll} from "./components/beta/userList"
@ -24,7 +25,8 @@ m.route(document.body, "/", {
"/login": loginUser, "/login": loginUser,
"/questionnaires": clientQuestionnaireList, "/questionnaires": clientQuestionnaireList,
"/questionnaires/:id": clientQuestionnaire, "/questionnaires/:id": clientQuestionnaire,
"/sections/:id": clientQuestion, "/sections/:sectionId": clientQuestion,
"/sections/:sectionId/questions/:questionId": clientQuestion,
"/questions/:id": clientQuestion, "/questions/:id": clientQuestion,
"/questions/:id/edit": editQuestion, "/questions/:id/edit": editQuestion,
"/user/questionnaires": questionnaireList, "/user/questionnaires": questionnaireList,

View File

@ -11,12 +11,14 @@ const QuestionAnswer = {
method: "GET" method: "GET"
}) })
.then(function(res) { .then(function(res) {
res.data = res.data[0]
QuestionAnswer.current = res
QuestionAnswer.loading = false QuestionAnswer.loading = false
console.log("response: ", res);
}) })
}, },
upload: function(questionId) { upload: function(questionId) {
QuestionAnswer.loading = true QuestionAnswer.loading = true
questionId = questionId || QuestionAnswer.current.questionId
m.request({ m.request({
url: "http://api.questionnaire.dev/v1/questions/" + questionId + "/answers", url: "http://api.questionnaire.dev/v1/questions/" + questionId + "/answers",
method: "POST", method: "POST",
@ -24,7 +26,6 @@ const QuestionAnswer = {
}) })
.then(function(res) { .then(function(res) {
QuestionAnswer.loading = false QuestionAnswer.loading = false
console.log("response: ", res);
}) })
} }
} }

View File

@ -4,15 +4,14 @@ const SectionQuestion = {
current: {}, current: {},
list: [], list: [],
loading: false, loading: false,
fetch: function(sectionId) { loadList: function(sectionId) {
SectionQuestion.loading = true SectionQuestion.loading = true
m.request({ m.request({
url: "http://api.questionnaire.dev/v1/sections/" + sectionId + "/questions", url: "http://api.questionnaire.dev/v1/sections/" + sectionId + "/questions",
method: "GET" method: "GET"
}) })
.then(function(res) { .then(function(res) {
res.data = res.data[0] SectionQuestion.list = res
SectionQuestion.current = res
SectionQuestion.loading = false SectionQuestion.loading = false
}) })
}, },

32
public/css/loading.css vendored Normal file
View File

@ -0,0 +1,32 @@
.signal {
border: 3px solid #333;
border-radius: 50px;
height: 50px;
left: 50%;
margin: -25px 0 0 -25px;
opacity: 0;
position: absolute;
top: 50%;
width: 50px;
animation: pulsate 1.2s ease-out;
animation-iteration-count: infinite;
}
.late {
animation-delay: .25s;
}
@keyframes pulsate {
0% {
transform: scale(.1);
opacity: 0.0;
}
50% {
opacity: 1;
}
100% {
transform: scale(1.2);
opacity: 0;
}
}

View File

@ -7,6 +7,7 @@
<link rel="stylesheet" href="css/index.css"> <link rel="stylesheet" href="css/index.css">
<link rel="stylesheet" href="css/font-awesome/css/font-awesome.min.css"> <link rel="stylesheet" href="css/font-awesome/css/font-awesome.min.css">
<link rel="stylesheet" href="css/patua-one-font.css"> <link rel="stylesheet" href="css/patua-one-font.css">
<link rel="stylesheet" href="css/loading.css">
</head> </head>
<body> <body>
<script src="js/index.js"></script> <script src="js/index.js"></script>

2078
public/js/index.js vendored

File diff suppressed because one or more lines are too long

1
webpack.config.js vendored
View File

@ -17,6 +17,7 @@ module.exports = {
{ from: 'assets/css/vendor/font-awesome', to: '../css/font-awesome' }, { from: 'assets/css/vendor/font-awesome', to: '../css/font-awesome' },
{ from: 'assets/css/index.css', to: '../css' }, { from: 'assets/css/index.css', to: '../css' },
{ from: 'assets/css/custom/patua-one-font.css', to: '../css' }, { from: 'assets/css/custom/patua-one-font.css', to: '../css' },
{ from: 'assets/css/custom/loading.css', to: '../css' },
{ from: 'assets/img', to: '../img' } { from: 'assets/img', to: '../img' }
]) ])
], ],