63 lines
1.4 KiB
JavaScript
Vendored
63 lines
1.4 KiB
JavaScript
Vendored
import m from "mithril"
|
|
|
|
export const Section = {
|
|
list: [],
|
|
current: {},
|
|
questions: [],
|
|
message: "",
|
|
error: "",
|
|
fetchList: function() {
|
|
m.request({
|
|
method: "GET",
|
|
url: "/sections"
|
|
})
|
|
.then(function(res) {
|
|
Section.list = res.data
|
|
})
|
|
},
|
|
fetchCurrent: function() {
|
|
m.request({
|
|
method: "GET",
|
|
url: "/sections",
|
|
data: Section.current
|
|
})
|
|
.then(function(res) {
|
|
Section.current = res.data
|
|
})
|
|
},
|
|
fetchQuestions: function() {
|
|
m.request({
|
|
method: "GET",
|
|
url: "/sections/:id/questions",
|
|
data: Section.current
|
|
}).
|
|
then(function(res) {
|
|
Section.questions = res.data
|
|
})
|
|
},
|
|
upload: function() {
|
|
m.request({
|
|
method: "POST",
|
|
url: "/questionnaires/:qId/sections",
|
|
data: _.assign(Section.current, {qId: Section.current.questionnaire.id})
|
|
})
|
|
},
|
|
uploadQuestion: function() {
|
|
|
|
},
|
|
update: function() {
|
|
m.request({
|
|
method: "PUT",
|
|
url: "/sections/:id",
|
|
data: Section.current
|
|
})
|
|
},
|
|
remove: function() {
|
|
m.request({
|
|
method: "DELETE",
|
|
url: "/sections/:id",
|
|
data: Section.current
|
|
})
|
|
}
|
|
}
|