liquid_feedback_frontend
annotate app/main/survey/_notification.lua @ 1735:5a8a09119865
Added survey feature
author | bsw |
---|---|
date | Fri Oct 08 00:09:23 2021 +0200 (2021-10-08) |
parents | |
children |
rev | line source |
---|---|
bsw@1735 | 1 if not app.session.member then |
bsw@1735 | 2 return |
bsw@1735 | 3 end |
bsw@1735 | 4 local survey = Survey:get_open() |
bsw@1735 | 5 |
bsw@1735 | 6 if not survey then |
bsw@1735 | 7 return |
bsw@1735 | 8 end |
bsw@1735 | 9 |
bsw@1735 | 10 local survey_member = SurveyMember:by_pk(survey.id, app.session.member_id) |
bsw@1735 | 11 |
bsw@1735 | 12 if not survey_member or survey_member.answer_set and not survey_member.finished then |
bsw@1735 | 13 slot.select("motd", function() |
bsw@1735 | 14 ui.container{ attr = { class = "mdl-card mdl-card__fullwidth mdl-shadow--2dp" }, content = function() |
bsw@1735 | 15 ui.container{ attr = { class = "mdl-card__content mdl-card--border" }, content = function() |
bsw@1735 | 16 ui.form{ |
bsw@1735 | 17 module = "survey", action = "participate", |
bsw@1735 | 18 routing = { |
bsw@1735 | 19 ok = { mode = "redirect", module = "survey", view = "participate" }, |
bsw@1735 | 20 error = { mode = "forward", module = "survey", view = "participate" }, |
bsw@1735 | 21 skip_survey = { mode = "redirect", module = "index", view = "index" }, |
bsw@1735 | 22 }, |
bsw@1735 | 23 content = function() |
bsw@1735 | 24 ui.heading{ content = survey.title } |
bsw@1735 | 25 ui.container{ content = function() |
bsw@1735 | 26 slot.put(survey.text) |
bsw@1735 | 27 end } |
bsw@1735 | 28 slot.put("<br>") |
bsw@1735 | 29 local start_text = _"Start survey" |
bsw@1735 | 30 local cancel_text = _"I don't want to particiapte" |
bsw@1735 | 31 if survey_member then |
bsw@1735 | 32 start_text = _"Continue survey" |
bsw@1735 | 33 cancel_text = _"Cancel survey" |
bsw@1735 | 34 end |
bsw@1735 | 35 ui.tag{ |
bsw@1735 | 36 tag = "input", |
bsw@1735 | 37 attr = { |
bsw@1735 | 38 type = "submit", |
bsw@1735 | 39 class = "mdl-button mdl-js-button mdl-button--raised mdl-button--colored", |
bsw@1735 | 40 value = start_text |
bsw@1735 | 41 }, |
bsw@1735 | 42 content = "" |
bsw@1735 | 43 } |
bsw@1735 | 44 slot.put(" ") |
bsw@1735 | 45 ui.tag{ |
bsw@1735 | 46 tag = "input", |
bsw@1735 | 47 attr = { |
bsw@1735 | 48 type = "submit", |
bsw@1735 | 49 name = "skip_survey", |
bsw@1735 | 50 class = "mdl-button mdl-js-button", |
bsw@1735 | 51 value = cancel_text |
bsw@1735 | 52 }, |
bsw@1735 | 53 content = "" |
bsw@1735 | 54 } |
bsw@1735 | 55 end |
bsw@1735 | 56 } |
bsw@1735 | 57 end } |
bsw@1735 | 58 end } |
bsw@1735 | 59 end) |
bsw@1735 | 60 end |
bsw@1735 | 61 |