Skip to content

armgit / core

Public Imported from GitHub
0

100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps

Improves or-survey and or-survey-results

robindekkers440b24eb9cf9
diff --git a/ui/component/or-survey-results/src/style.ts b/ui/component/or-survey-results/src/style.ts
index 216006e77..1d7b25162 100644
--- a/ui/component/or-survey-results/src/style.ts
+++ b/ui/component/or-survey-results/src/style.ts
@@ -69,7 +69,6 @@ export const surveyResultStyle = html`
}
.label-x {
- display: block;
display: block;
margin: 0 10px;
}
@@ -77,7 +76,7 @@ export const surveyResultStyle = html`
#chart-container {
padding-top: 20px;
margin: auto;
- max-width: 860px;
+ width: 100%;
overflow-x: scroll;
}
@@ -176,18 +175,6 @@ export const surveyResultStyle = html`
}
}
- @media (max-width: 1640px) {
- #chart-container {
- max-width: 450px;
- }
- }
-
- @media (max-width: 768px) {.anwser-card:nth-of-type(5n+5) {
- #chart-container {
- max-width: 100%;
- }
- }
-
</style>
`;
\ No newline at end of file
diff --git a/ui/component/or-survey/src/index.ts b/ui/component/or-survey/src/index.ts
index ace96b6a2..3b4d3b8e6 100644
--- a/ui/component/or-survey/src/index.ts
+++ b/ui/component/or-survey/src/index.ts
@@ -9,7 +9,7 @@ import orderBy from "lodash-es/orderBy";
import * as momentImported from 'moment'; const moment = momentImported;
import manager, { OREvent, EventCallback } from "@openremote/core";
import filter from "lodash-es/filter";
-
+import "@openremote/or-translate";
declare var MANAGER_URL: string;
export interface AnswerOption {
@@ -60,8 +60,12 @@ class OrSurvey extends LitElement {
@property({type: Boolean})
public hasSubmission?: boolean;
+ @property({type: Boolean})
public previousButton?: boolean;
+
+ @property({type: Boolean})
public nextButton?: boolean;
+
public questionAnimation?: string;
protected _initCallback?: EventCallback;
@@ -93,7 +97,7 @@ class OrSurvey extends LitElement {
return html`
${surveySectionStyle}
${surveyLayoutStyle}
- <div id="surveyQuestions">
+ <div id="surveyQuestions">
${this.completed || this.hasSubmission ? html`
<p>${this.survey.attributes ? this.survey.attributes.thankYouMessage.value : ''}</p>
${!this.saveanswers ? html`
@@ -260,7 +264,7 @@ class OrSurvey extends LitElement {
}
checkButtons() {
- if(!this.survey || !this.questions || typeof this.questionIndex === "undefined") {
+ if(!this.survey || !this.questions || typeof this.questionIndex === "undefined") {
return;
}
@@ -316,8 +320,8 @@ class OrSurvey extends LitElement {
this.questionIndexLabel = 1;
this.nextButtonLabel = "Next";
this.completed = false;
- this.nextButton = true;
this.surveyAnswers = {};
+ this.checkButtons();
}
previousQuestion() {
@@ -335,7 +339,7 @@ class OrSurvey extends LitElement {
if(!this.questions || typeof this.questionIndex === 'undefined' || typeof this.questionIndexLabel === 'undefined' ) {
return;
}
- const target = e.target;
+ const target = e.currentTarget;
let surveyAnswers = this.surveyAnswers;
let currQuestion:Asset = this.questions[this.questionIndex];
if (this.getType(currQuestion.type) === "singleSelect" || this.getType(currQuestion.type) === "rating") {
@@ -397,16 +401,17 @@ class OrSurvey extends LitElement {
let surveyId: string;
if (location.hash.indexOf('survey') != -1) {
surveyId = location.hash.split(':')[1];
+ if(!surveyId) {
+ this.checkButtons();
+ return;
+ }
} else if(this.surveyId){
surveyId = this.surveyId;
} else {
+ this.checkButtons();
return;
}
- if(localStorage.getItem('survey'+surveyId)){
- this.hasSubmission = true;
- return;
- }
const surveyQuery: AssetQuery = {
select: {
@@ -429,6 +434,11 @@ class OrSurvey extends LitElement {
console.error("Error: " + reason);
});
+ if(localStorage.getItem('survey'+surveyId)){
+ this.hasSubmission = true;
+ return;
+ }
+
const questionQuery: AssetQuery = {
select: {
excludeAttributeMeta: false,
@@ -448,6 +458,8 @@ class OrSurvey extends LitElement {
if(this.survey){
this.questions = filter(this.questions, ['parentId', this.survey.id]);
}
+
+ this.checkButtons();
this.requestUpdate();
}
}).catch((reason) => {