Filling questionnaire process for client now works like a charm
This commit is contained in:
1058
assets/js/components/client/question.js
vendored
1058
assets/js/components/client/question.js
vendored
File diff suppressed because it is too large
Load Diff
23
assets/js/components/client/questionnaire.js
vendored
23
assets/js/components/client/questionnaire.js
vendored
@@ -1,23 +1,20 @@
|
||||
import m from "mithril"
|
||||
import { Card, RaisedButton } from "polythene-mithril"
|
||||
import { Card, Button } from "polythene-mithril"
|
||||
import Questionnaire from "../../models/Questionnaire"
|
||||
import QuestionnaireSection from "../../models/QuestionnaireSection"
|
||||
|
||||
export const questionnaire = {
|
||||
oninit: function(vnode) {
|
||||
window.scrollTo(0, 0)
|
||||
if (
|
||||
_.isEmpty(QuestionnaireSection.current)
|
||||
|| _.isNil(QuestionnaireSection.current)
|
||||
|| _.isEmpty(Questionnaire.current)
|
||||
|| _.isNil(Qustionnaire.current)
|
||||
) {
|
||||
Questionnaire.fetch(vnode.attrs.id)
|
||||
QuestionnaireSection.fetch(vnode.attrs.id)
|
||||
}
|
||||
Questionnaire.fetch(vnode.attrs.id)
|
||||
QuestionnaireSection.fetch(vnode.attrs.id)
|
||||
},
|
||||
view: function() {
|
||||
return [
|
||||
oncreate: function(vnode) {
|
||||
window.scrollTo(0, 0)
|
||||
},
|
||||
view: function(vnode) {
|
||||
return _.isEmpty(Questionnaire.current)
|
||||
|| _.isEmpty(QuestionnaireSection.current) ?
|
||||
[m(".signal"), m(".signal.late")] : [
|
||||
m(".header-img", {
|
||||
style: {
|
||||
backgroundImage: "url('img/head1.jpg')"
|
||||
|
||||
4
assets/js/index.js
vendored
4
assets/js/index.js
vendored
@@ -11,6 +11,7 @@ import { section } from "./components/section"
|
||||
import { editSection } from "./components/editSection"
|
||||
import { question } from "./components/question"
|
||||
import clientQuestion from "./components/client/question"
|
||||
import clientQuestionRedirect from "./components/client/questionRedirect"
|
||||
import { editQuestion } from "./components/editQuestion"
|
||||
import signup from "./components/hello"
|
||||
import {userList, userAll} from "./components/beta/userList"
|
||||
@@ -24,7 +25,8 @@ m.route(document.body, "/", {
|
||||
"/login": loginUser,
|
||||
"/questionnaires": clientQuestionnaireList,
|
||||
"/questionnaires/:id": clientQuestionnaire,
|
||||
"/sections/:id": clientQuestion,
|
||||
"/sections/:sectionId": clientQuestion,
|
||||
"/sections/:sectionId/questions/:questionId": clientQuestion,
|
||||
"/questions/:id": clientQuestion,
|
||||
"/questions/:id/edit": editQuestion,
|
||||
"/user/questionnaires": questionnaireList,
|
||||
|
||||
5
assets/js/models/QuestionAnswer.js
vendored
5
assets/js/models/QuestionAnswer.js
vendored
@@ -11,12 +11,14 @@ const QuestionAnswer = {
|
||||
method: "GET"
|
||||
})
|
||||
.then(function(res) {
|
||||
res.data = res.data[0]
|
||||
QuestionAnswer.current = res
|
||||
QuestionAnswer.loading = false
|
||||
console.log("response: ", res);
|
||||
})
|
||||
},
|
||||
upload: function(questionId) {
|
||||
QuestionAnswer.loading = true
|
||||
questionId = questionId || QuestionAnswer.current.questionId
|
||||
m.request({
|
||||
url: "http://api.questionnaire.dev/v1/questions/" + questionId + "/answers",
|
||||
method: "POST",
|
||||
@@ -24,7 +26,6 @@ const QuestionAnswer = {
|
||||
})
|
||||
.then(function(res) {
|
||||
QuestionAnswer.loading = false
|
||||
console.log("response: ", res);
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
5
assets/js/models/SectionQuestion.js
vendored
5
assets/js/models/SectionQuestion.js
vendored
@@ -4,15 +4,14 @@ const SectionQuestion = {
|
||||
current: {},
|
||||
list: [],
|
||||
loading: false,
|
||||
fetch: function(sectionId) {
|
||||
loadList: function(sectionId) {
|
||||
SectionQuestion.loading = true
|
||||
m.request({
|
||||
url: "http://api.questionnaire.dev/v1/sections/" + sectionId + "/questions",
|
||||
method: "GET"
|
||||
})
|
||||
.then(function(res) {
|
||||
res.data = res.data[0]
|
||||
SectionQuestion.current = res
|
||||
SectionQuestion.list = res
|
||||
SectionQuestion.loading = false
|
||||
})
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user