From b57bd05b33f78e2385a01ce36df7f036cc01378c Mon Sep 17 00:00:00 2001 From: mwasiluk Date: Sat, 20 Aug 2016 14:19:52 +0200 Subject: [PATCH] #14 grid question - configurable cell input type --- demo/form-data.json | 1 + dist/form-builder-bootstrap-tpls.min.js | 4 +- dist/form-builder-material-tpls.min.js | 4 +- dist/form-builder.min.js | 16 +-- dist/form-utils.min.js | 2 +- dist/form-viewer-bootstrap-tpls.min.js | 2 +- dist/form-viewer-material-tpls.min.js | 2 +- dist/form-viewer.min.js | 4 +- dist/i18n/en/angular-surveys.json | 2 +- dist/i18n/es/angular-surveys.json | 2 +- dist/i18n/pl/angular-surveys.json | 2 +- i18n/en/angular-surveys.json | 9 ++ i18n/es/angular-surveys.json | 10 ++ i18n/pl/angular-surveys.json | 9 ++ src/builder/form-builder-options.service.js | 1 + .../question-grid-builder.directive.js | 8 +- .../bootstrap/mw-form-question-builder.html | 10 +- .../bootstrap/mw-question-grid-builder.html | 8 ++ .../material/mw-form-question-builder.html | 11 ++- .../material/mw-question-grid-builder.html | 18 +++- src/utils/form-response-utils.service.js | 98 ++++++++++++++++--- src/viewer/form-question.directive.js | 3 + .../templates/bootstrap/mw-form-question.html | 7 +- .../templates/material/mw-form-question.html | 11 ++- 24 files changed, 199 insertions(+), 45 deletions(-) diff --git a/demo/form-data.json b/demo/form-data.json index 91a7389..a1b1e7c 100644 --- a/demo/form-data.json +++ b/demo/form-data.json @@ -122,6 +122,7 @@ "type": "grid", "required": true, "grid": { + "cellInputType": "radio", "rows": [ { "id": "36683a4385337df9ab6b580207272b5b", diff --git a/dist/form-builder-bootstrap-tpls.min.js b/dist/form-builder-bootstrap-tpls.min.js index 8d13bb8..9beb67d 100644 --- a/dist/form-builder-bootstrap-tpls.min.js +++ b/dist/form-builder-bootstrap-tpls.min.js @@ -1,2 +1,2 @@ -angular.module("mwFormBuilder").run(["$templateCache",function(e){e.put("mw-form-builder.html",'
{{ctrl.currentPage + 1}}/{{ctrl.numberOfPages()}}
'),e.put("mw-form-confirmation-page-builder.html",'
Strona potwierdzenia
'),e.put("mw-form-image-builder.html",'


{{ctrl.image.caption}}
'),e.put("mw-form-page-builder.html",'
Strona 1 z 3
Brak elementów
'),e.put("mw-form-page-element-builder.html",'
'),e.put("mw-form-paragraph-builder.html",'

'),e.put("mw-form-question-builder.html",'
Min: Max:

Range from to



{{ctrl.question.text}} *
{{row.label}}
SortedAvailable
{{::item.value}}
{{ctrl.question.unit}}
{{ctrl.question.unit}} z wymaganych {{ctrl.question.quantity}} {{ctrl.question.unit}}
'),e.put("mw-label.html",""),e.put("mw-question-division-builder.html",'
'),e.put("mw-question-grid-builder.html",'
'),e.put("mw-question-offered-answer-list-builder.html",'
lub
'),e.put("mw-question-priority-list-builder.html",'
'); -}]); \ No newline at end of file +angular.module("mwFormBuilder").run(["$templateCache",function(e){e.put("mw-form-builder.html",'
{{ctrl.currentPage + 1}}/{{ctrl.numberOfPages()}}
'),e.put("mw-form-confirmation-page-builder.html",'
Strona potwierdzenia
'),e.put("mw-form-image-builder.html",'


{{ctrl.image.caption}}
'),e.put("mw-form-page-builder.html",'
Strona 1 z 3
Brak elementów
'),e.put("mw-form-page-element-builder.html",'
'),e.put("mw-form-paragraph-builder.html",'

'),e.put("mw-form-question-builder.html",'
Min: Max:

Range from to



{{ctrl.question.text}} *
{{row.label}}
SortedAvailable
{{::item.value}}
{{ctrl.question.unit}}
{{ctrl.question.unit}} z wymaganych {{ctrl.question.quantity}} {{ctrl.question.unit}}
'),e.put("mw-label.html",""),e.put("mw-question-division-builder.html",'
'),e.put("mw-question-grid-builder.html",'
'),e.put("mw-question-offered-answer-list-builder.html",'
lub
'), +e.put("mw-question-priority-list-builder.html",'
')}]); \ No newline at end of file diff --git a/dist/form-builder-material-tpls.min.js b/dist/form-builder-material-tpls.min.js index f1f87e3..466207e 100644 --- a/dist/form-builder-material-tpls.min.js +++ b/dist/form-builder-material-tpls.min.js @@ -1,2 +1,2 @@ -angular.module("mwFormBuilder").run(["$templateCache",function(t){t.put("mw-form-builder.html",'
{{ctrl.currentPage + 1}}/{{ctrl.numberOfPages()}}
{{item}}
'),t.put("mw-form-confirmation-page-builder.html",'
Strona potwierdzenia
'),t.put("mw-form-image-builder.html",'
Image caption


Ready
{{ctrl.image.caption}}
'),t.put("mw-form-page-builder.html",'
Strona 1 z 3
Brak elementów
Add elementPytanieObrazObraz
'),t.put("mw-form-page-element-builder.html",'
'),t.put("mw-form-paragraph-builder.html",'

Ready

'),t.put("mw-form-question-builder.html",'
{{\'mwForm.question.types.\'+type+\'.name\'|translate}}
Przejdź do strony w oparciu o odpowiedź




Ready
Required
{{ctrl.question.text}} *
{{answer.value}}
Inna:
{{answer.value}}
Inna:
{{answer.value}}
{{row.label}}
SortedAvailable
{{::item.value}}
{{ctrl.question.unit}}
{{ctrl.question.unit}} z wymaganych {{ctrl.question.quantity}} {{ctrl.question.unit}}
'),t.put("mw-label.html",""),t.put("mw-question-division-builder.html",'
{{\'mwForm.buttons.remove\' | translate}}
'),t.put("mw-question-grid-builder.html",'
{{\'mwForm.buttons.remove\' | translate}}
{{\'mwForm.buttons.remove\' | translate}}
'),t.put("mw-question-offered-answer-list-builder.html",'
{{\'mwForm.buttons.remove\' | translate}}{{ pageFlow.label|translate:pageFlow }}
orDodaj "Inne"
{{\'mwForm.buttons.remove\' | translate}}
'), -t.put("mw-question-priority-list-builder.html",'
{{\'mwForm.buttons.remove\' | translate}}
')}]); \ No newline at end of file +angular.module("mwFormBuilder").run(["$templateCache",function(t){t.put("mw-form-builder.html",'
{{ctrl.currentPage + 1}}/{{ctrl.numberOfPages()}}
{{item}}
'),t.put("mw-form-confirmation-page-builder.html",'
Strona potwierdzenia
'),t.put("mw-form-image-builder.html",'
Image caption


Ready
{{ctrl.image.caption}}
'),t.put("mw-form-page-builder.html",'
Strona 1 z 3
Brak elementów
Add elementPytanieObrazObraz
'),t.put("mw-form-page-element-builder.html",'
'),t.put("mw-form-paragraph-builder.html",'

Ready

'),t.put("mw-form-question-builder.html",'
{{\'mwForm.question.types.\'+type+\'.name\'|translate}}
Przejdź do strony w oparciu o odpowiedź




Ready
Required
{{ctrl.question.text}} *
{{answer.value}}
Inna:
{{answer.value}}
Inna:
{{answer.value}}
{{row.label}}
SortedAvailable
{{::item.value}}
{{ctrl.question.unit}}
{{ctrl.question.unit}} z wymaganych {{ctrl.question.quantity}} {{ctrl.question.unit}}
'),t.put("mw-label.html",""),t.put("mw-question-division-builder.html",'
{{\'mwForm.buttons.remove\' | translate}}
'),t.put("mw-question-grid-builder.html",'
{{\'mwForm.question.grid.cellInputTypes.\'+opt|translate}}
{{\'mwForm.buttons.remove\' | translate}}
{{\'mwForm.buttons.remove\' | translate}}
'), +t.put("mw-question-offered-answer-list-builder.html",'
{{\'mwForm.buttons.remove\' | translate}}{{ pageFlow.label|translate:pageFlow }}
orDodaj "Inne"
{{\'mwForm.buttons.remove\' | translate}}
'),t.put("mw-question-priority-list-builder.html",'
{{\'mwForm.buttons.remove\' | translate}}
')}]); \ No newline at end of file diff --git a/dist/form-builder.min.js b/dist/form-builder.min.js index 0707e25..62f2cec 100644 --- a/dist/form-builder.min.js +++ b/dist/form-builder.min.js @@ -1,17 +1,17 @@ angular.module("mwFormBuilder",["ngSanitize","ng-sortable","pascalprecht.translate"]); angular.module("mwFormBuilder").service("mwFormUuid",function(){function r(){return Math.floor(65536*(1+Math.random())).toString(16).substring(1)}this.get=function(){return r()+r()+r()+r()+r()+r()+r()+r()}}).factory("mwFormClone",["mwFormUuid",function(r){var e={},n=[];return e.resetIds=function(t,a){if(a&&(n=[]),!(n.indexOf(t)>=0)&&(n.push(t),!t!==Object(t))){if(Array.isArray(t))return void t.forEach(e.resetIds);for(var o in t)t.hasOwnProperty(o)&&e.resetIds(t[o]);if(t.hasOwnProperty("id")){var i=r.get();t.id;t.id=i}}},e.cloneElement=function(r){var n={};return angular.copy(r,n),e.resetIds(n,!0),n},e.clonePage=function(n){var t={};angular.copy(n,t),t.id=r.get();var a=[];if(Array.isArray(n.elements))for(var o=0;o=0&&a(i.formPage.elements,n,o),r()},i.isElementTypeEnabled=function(e){return-1!==t.elementTypes.indexOf(e)},i.addQuestion=function(){i.addElement("question")},i.addImage=function(){i.addElement("image")},i.addParagraph=function(){i.addElement("paragraph")},i.isElementActive=function(e){return i.activeElement==e},i.selectElement=function(e){i.activeElement=e},i.onElementReady=function(){e(function(){i.activeElement=null})},i.hoverIn=function(){i.hoverEdit=!0},i.hoverOut=function(){i.hoverEdit=!1},i.updateElementsOrderNo=r}],link:function(e,n,o,t){var r=e.ctrl;r.possiblePageFlow=t.possiblePageFlow,r.moveDown=function(){t.moveDownPage(r.formPage)},r.moveUp=function(){t.moveUpPage(r.formPage)},r.removePage=function(){t.removePage(r.formPage)},r.addPage=function(){t.addPageAfter(r.formPage)},e.$watch("ctrl.formPage.elements.length",function(e,n){e!=n&&r.updateElementsOrderNo()}),r.options=t.options,r.onImageSelection=t.onImageSelection}}}); +angular.module("mwFormBuilder").directive("mwFormPageElementBuilder",function(){return{replace:!0,restrict:"AE",require:"^mwFormPageBuilder",scope:{pageElement:"=",formObject:"=",isActive:"=",isFirst:"=",isLast:"=",onReady:"&",readOnly:"=?"},templateUrl:"mw-form-page-element-builder.html",controllerAs:"ctrl",bindToController:!0,controller:["mwFormUuid",function(e){var t=this;t.callback=function(e,n){e.preventDefault(),e.stopPropagation(),n.callback&&"function"==typeof n.callback&&n.callback(t.pageElement)},t.filter=function(e){return!(!e.showInOpen&&t.isActive)&&(!(!e.showInPreview&&!t.isActive)&&(!e.filter||"function"!=typeof e.filter||e.filter(t.pageElement)))},"question"==t.pageElement.type?t.pageElement.question||(t.pageElement.question={id:e.get(),text:null,type:null,required:!0}):"image"==t.pageElement.type?t.pageElement.image||(t.pageElement.image={id:e.get(),align:"left"}):"paragraph"==t.pageElement.type&&(t.pageElement.paragraph||(t.pageElement.paragraph={id:e.get(),html:""}))}],link:function(e,t,n,l){var o=e.ctrl;o.possiblePageFlow=l.possiblePageFlow,o.hoverIn=function(){o.isHovered=!0},o.hoverOut=function(){o.isHovered=!1},o.editElement=function(){l.selectElement(o.pageElement)},o.cloneElement=function(e){e.preventDefault(),e.stopPropagation(),l.cloneElement(o.pageElement)},o.removeElement=function(){l.removeElement(o.pageElement)},o.moveDown=function(){l.moveDownElement(o.pageElement)},o.moveUp=function(){l.moveUpElement(o.pageElement)},o.options=l.options,o.onImageSelection=l.onImageSelection}}}); +angular.module("mwFormBuilder").directive("mwFormPageBuilder",function(){return{replace:!0,restrict:"AE",require:"^mwFormBuilder",scope:{formPage:"=",formObject:"=",isFirst:"=",isLast:"=",readOnly:"=?"},templateUrl:"mw-form-page-builder.html",controllerAs:"ctrl",bindToController:!0,controller:["$timeout","mwFormUuid","mwFormClone","mwFormBuilderOptions",function(e,n,o,t){function r(){for(var e=0;e=0&&a(i.formPage.elements,n,o),r()},i.isElementTypeEnabled=function(e){return t.elementTypes.indexOf(e)!==-1},i.addQuestion=function(){i.addElement("question")},i.addImage=function(){i.addElement("image")},i.addParagraph=function(){i.addElement("paragraph")},i.isElementActive=function(e){return i.activeElement==e},i.selectElement=function(e){i.activeElement=e},i.onElementReady=function(){e(function(){i.activeElement=null})},i.hoverIn=function(){i.hoverEdit=!0},i.hoverOut=function(){i.hoverEdit=!1},i.updateElementsOrderNo=r}],link:function(e,n,o,t){var r=e.ctrl;r.possiblePageFlow=t.possiblePageFlow,r.moveDown=function(){t.moveDownPage(r.formPage)},r.moveUp=function(){t.moveUpPage(r.formPage)},r.removePage=function(){t.removePage(r.formPage)},r.addPage=function(){t.addPageAfter(r.formPage)},e.$watch("ctrl.formPage.elements.length",function(e,n){e!=n&&r.updateElementsOrderNo()}),r.options=t.options,r.onImageSelection=t.onImageSelection}}}); angular.module("mwFormBuilder").factory("FormImageBuilderId",function(){var e=0;return{next:function(){return++e}}}).directive("mwFormImageBuilder",function(){return{replace:!0,restrict:"AE",require:"^mwFormPageElementBuilder",scope:{image:"=",formObject:"=",onReady:"&",isPreview:"=?",readOnly:"=?",onImageSelection:"&"},templateUrl:"mw-form-image-builder.html",controllerAs:"ctrl",bindToController:!0,controller:["$timeout","FormImageBuilderId","mwFormUuid",function(e,r,t){var n=this;n.id=r.next(),n.formSubmitted=!1,n.save=function(){n.formSubmitted=!0,n.form.$valid&&n.onReady()},n.selectImageButtonClicked=function(){var e=n.onImageSelection();e.then(function(e){n.image.src=e})["catch"](function(){})},n.setAlign=function(e){n.image.align=e}}],link:function(e,r,t,n){e.ctrl}}}); angular.module("mwFormBuilder").directive("mwFormConfirmationPageBuilder",function(){return{replace:!0,restrict:"AE",scope:{formObject:"=",readOnly:"=?"},templateUrl:"mw-form-confirmation-page-builder.html",controllerAs:"ctrl",bindToController:!0,controller:["$timeout",function(r){var o=this;o.hoverEdit=!1,o.hoverIn=function(){o.hoverEdit=!0},o.hoverOut=function(){o.hoverEdit=!1}}],link:function(r,o,e){}}}); angular.module("mwFormBuilder").directive("mwFormBuilder",function(){return{replace:!0,restrict:"AE",scope:{formData:"=",readOnly:"=?",options:"=?",formStatus:"=?",onImageSelection:"&",api:"=?"},templateUrl:"mw-form-builder.html",controllerAs:"ctrl",bindToController:!0,controller:["mwFormUuid","MW_QUESTION_TYPES","mwFormBuilderOptions",function(e,a,o){function t(a){var o=null;return g.possiblePageFlow&&(o=g.possiblePageFlow[0]),{id:e.get(),number:a,name:null,description:null,pageFlow:o,elements:[]}}function r(){for(var e=0;eMath.ceil(g.formData.pages.length/g.pageSize-1)&&(g.currentPage=Math.ceil(g.formData.pages.length/g.pageSize-1))},g.addPageAfter=function(e){var a=g.formData.pages.indexOf(e),o=a+1,n=t(e.number+1);o=0&&n(g.formData.pages,a,o),r()},g.removePage=function(e){var a=g.formData.pages.indexOf(e);g.formData.pages.splice(a,1),r()},g.api&&(g.api.reset=function(){for(var e in g.formData)g.formData.hasOwnProperty(e)&&"pages"!=e&&delete g.formData[e];g.formData.pages.length=0,g.formData.pages.push(t(1))})}],link:function(e,a,o){var t=e.ctrl;t.formStatus&&(t.formStatus.form=t.form),t.possiblePageFlow=[];var r={nextPage:!0,label:"mwForm.pageFlow.goToNextPage"};t.possiblePageFlow.push(r),t.isSamePageFlow=function(e,a){return e.page&&a.page&&e.page.id==a.page.id||e.formSubmit&&a.formSubmit||e.nextPage&&a.nextPage},t.updatePageFlow=function(){t.possiblePageFlow.length=1,t.formData.pages.forEach(function(e){t.possiblePageFlow.push({page:{id:e.id,number:e.number},label:"mwForm.pageFlow.goToPage"})}),t.possiblePageFlow.push({formSubmit:!0,label:"mwForm.pageFlow.submitForm"}),t.formData.pages.forEach(function(e){t.possiblePageFlow.forEach(function(a){e.pageFlow?t.isSamePageFlow(a,e.pageFlow)&&(e.pageFlow=a):e.pageFlow=r,e.elements.forEach(function(e){var o=e.question;o&&o.pageFlowModifier&&o.offeredAnswers.forEach(function(e){e.pageFlow&&t.isSamePageFlow(a,e.pageFlow)&&(e.pageFlow=a)})})})})},e.$watch("ctrl.formData.pages.length",function(e,a){t.updatePageFlow()})}}}),angular.module("mwFormBuilder").filter("mwStartFrom",function(){return function(e,a){return a=+a,e.slice(a)}}); -angular.module("mwFormBuilder").constant("MW_QUESTION_TYPES",["text","textarea","radio","checkbox","select","grid","priority","division","number","date","time","email","range","url"]).constant("MW_ELEMENT_TYPES",["question","image","paragraph"]).factory("mwFormBuilderOptions",["MW_ELEMENT_TYPES","MW_QUESTION_TYPES",function(e,t){function n(e,t){return e?e.map(function(e){return angular.extend({},t,e)}):[]}var l={title:null,icon:null,text:null,callback:null,filter:null,showInOpen:!1,showInPreview:!0,cssClass:""},u={key:null,label:null,selects:[],required:!0},r={elementTypes:e,questionTypes:t,elementButtons:[],customQuestionSelects:[],customElements:[]},s={$init:function(e){return angular.extend(s,r,e),s.customQuestionSelects=n(s.customQuestionSelects,u),s.elementButtons=n(s.elementButtons,l),s}};return s}]); +angular.module("mwFormBuilder").constant("MW_QUESTION_TYPES",["text","textarea","radio","checkbox","select","grid","priority","division","number","date","time","email","range","url"]).constant("MW_ELEMENT_TYPES",["question","image","paragraph"]).constant("MW_GRID_CELL_INPUT_TYPES",["radio","checkbox","text","number","date","time"]).factory("mwFormBuilderOptions",["MW_ELEMENT_TYPES","MW_QUESTION_TYPES",function(e,t){function n(e,t){return e?e.map(function(e){return angular.extend({},t,e)}):[]}var l={title:null,icon:null,text:null,callback:null,filter:null,showInOpen:!1,showInPreview:!0,cssClass:""},u={key:null,label:null,selects:[],required:!0},o={elementTypes:e,questionTypes:t,elementButtons:[],customQuestionSelects:[],customElements:[]},r={$init:function(e){return angular.extend(r,o,e),r.customQuestionSelects=n(r.customQuestionSelects,u),r.elementButtons=n(r.elementButtons,l),r}};return r}]); angular.module("mwFormBuilder").directive("wdFocusMe",["$timeout","$parse",function(n,u){return{link:function(o,t,c){var i=u(c.wdFocusMe);o.$watch(i,function(u){u===!0&&n(function(){t[0].focus()})}),t.bind("blur",function(){o.$apply(i.assign(o,!1))})}}}]).factory("focus",["$timeout","$window",function(n,u){return function(o){n(function(){var n=u.document.getElementById(o);n&&n.focus()})}}]); "use strict";angular.module("mwFormBuilder").directive("mwConfirmClick",["$window",function(i){return{restrict:"A",link:function(n,r,c){var o=c.wdConfirmClick||"Are you sure?";r.bind("click",function(r){i.confirm(o)&&n.$apply(c.confirmedAction)})}}}]); \ No newline at end of file diff --git a/dist/form-utils.min.js b/dist/form-utils.min.js index 98e82c4..1af95e3 100644 --- a/dist/form-utils.min.js +++ b/dist/form-utils.min.js @@ -1,2 +1,2 @@ angular.module("mwFormUtils",["mwFormUtils.responseUtils"]); -angular.module("mwFormUtils.responseUtils",[]).factory("mwFormResponseUtils",function(){var e={},t=["text","textarea","number","date","time","email","range","url"];return e.$getObjectByIdMap=function(e,t){var r={};return e?(e.forEach(function(e){var i=e;t&&(i=t(e)),r[e.id]=i}),r):r},e.$getOfferedAnswerByIdMap=function(t){return e.$getObjectByIdMap(t.offeredAnswers,function(e){return{id:e.id,value:e.value}})},e.$extractResponseForQuestionWithOfferedAnswers=function(t,r){var i=e.$getOfferedAnswerByIdMap(t),n={};return r.selectedAnswers?(n.selectedAnswers=[],r.selectedAnswers.forEach(function(e){n.selectedAnswers.push(i[e])})):r.selectedAnswer&&(n.selectedAnswer=i[r.selectedAnswer]),r.other&&(n.other=r.other),n},e.$extractResponseForPriorityQuestion=function(t,r){var i=[];if(!r.priorityList)return i;var n=e.$getObjectByIdMap(t.priorityList);return r.priorityList.forEach(function(e){var t=n[e.id];i.push({id:t.id,value:t.value,priority:e.priority})}),i},e.$extractResponseForDivisionQuestion=function(t,r){var i=[],n=e.$getObjectByIdMap(t.divisionList);return Object.getOwnPropertyNames(r).forEach(function(e){var t=r[e],s=n[e];s&&i.push({id:s.id,label:s.value,value:t})}),i},e.$extractResponseForGridQuestion=function(t,r){var i=[];if(!t.grid||!t.grid.rows)return i;var n=e.$getObjectByIdMap(t.grid.cols);return t.grid.rows.forEach(function(e){var t=r[e.id],s=null;t&&(s=n[t]);var o={row:{id:e.id,label:e.label},col:null};s&&(o.col={id:s.id,label:s.label}),i.push(o)}),i},e.extractResponse=function(r,i){return-1!==t.indexOf(r.type)?i.answer:"radio"==r.type||"checkbox"==r.type||"select"==r.type?e.$extractResponseForQuestionWithOfferedAnswers(r,i):"grid"==r.type?e.$extractResponseForGridQuestion(r,i):"priority"==r.type?e.$extractResponseForPriorityQuestion(r,i):"division"==r.type?e.$extractResponseForDivisionQuestion(r,i):null},e.mergeFormWithResponse=function(t,r){var i={};return angular.copy(t,i),i.pages.forEach(function(t){t.elements.forEach(function(t){var i=t.question;if(i){var n=r[i.id];n&&(i.response=e.extractResponse(i,n))}})}),i},e.getQuestionList=function(e,t){var r=[];return e.pages.forEach(function(e){e.elements.forEach(function(e){if(e.question){var i=e.question;t&&(i={},angular.copy(e.question,i)),r.push(i)}})}),r},e.getQuestionWithResponseList=function(t,r){var i=[];return e.getQuestionList(t,!0).forEach(function(t){var n=r[t.id];n?t.response=e.extractResponse(t,n):t.response=null,i.push(t)}),i},e.$$getHeader=function(e,t,r,i,n){var s="";return n&&((e||0===e)&&(s+=e+"."),(r||0===r)&&(s+=r+"."),s.length&&(s+=" ")),s+=t,i&&(s+=" ["+i+"]"),s},e.getResponseSheetHeaders=function(t,r){var i=["grid","priority","division"],n=[],s=0;return e.getQuestionList(t).forEach(function(t){s++;var o=1;if(-1===i.indexOf(t.type))n.push(e.$$getHeader(s,t.text,null,null,r));else if("grid"==t.type){if(!t.grid)return;t.grid.rows.forEach(function(i){n.push(e.$$getHeader(s,t.text,o,i.label,r)),o++})}else if("priority"==t.type){if(!t.priorityList)return;t.priorityList.forEach(function(i){n.push(e.$$getHeader(s,t.text,o,i.value,r)),o++})}else if("division"==t.type){if(!t.divisionList)return;t.divisionList.forEach(function(i){n.push(e.$$getHeader(s,t.text,o,i.value,r)),o++})}}),n},e.getResponseSheetRow=function(t,r){var i="; ",n=[];if(!r)return n;for(var s=e.getQuestionWithResponseList(t,r),o=["radio","checkbox","select","grid","priority","division"],u=0;u
{{::ctrl.print(ctrl.confirmationMessage)}} Twoja odpowiedź została zapisana
Bład. Twoja odpowiedź nie została zapisana.
Zapisywanie odpowiedzi w trakcie.
"),e.put("mw-form-question.html",'
{{::ctrl.print(ctrl.question.text)}} *
{{::ctrl.print(row.label)}}
{{::ctrl.print(ctrl.question.unit)}}
{{ctrl.question.unit}} z wymaganych {{ctrl.question.quantity}} {{ctrl.question.unit}}
{{ctrl.questionResponse.answer}}
'),e.put("mw-form-viewer-content.html",'

{{ctrl.formData.name}}

{{ctrl.formData.description}}

{{ctrl.currentPage.name}}

{{pageElement.image.caption}}

'),e.put("mw-form-viewer.html","
"),e.put("mw-priority-list.html",'
SortedAvailable
{{$index+1}}. {{::ctrl.print(ctrl.idToItem[item.id].value)}}
{{::ctrl.print(ctrl.idToItem[item.id].value)}}
')}]); \ No newline at end of file +angular.module("mwFormViewer").run(["$templateCache",function(e){e.put("mw-form-confirmation-page.html","
{{::ctrl.print(ctrl.confirmationMessage)}} Twoja odpowiedź została zapisana
Bład. Twoja odpowiedź nie została zapisana.
Zapisywanie odpowiedzi w trakcie.
"),e.put("mw-form-question.html",'
{{::ctrl.print(ctrl.question.text)}} *
{{::ctrl.print(row.label)}}
{{::ctrl.print(ctrl.question.unit)}}
{{ctrl.question.unit}} z wymaganych {{ctrl.question.quantity}} {{ctrl.question.unit}}
{{ctrl.questionResponse.answer}}
'),e.put("mw-form-viewer-content.html",'

{{ctrl.formData.name}}

{{ctrl.formData.description}}

{{ctrl.currentPage.name}}

{{pageElement.image.caption}}

'),e.put("mw-form-viewer.html","
"),e.put("mw-priority-list.html",'
SortedAvailable
{{$index+1}}. {{::ctrl.print(ctrl.idToItem[item.id].value)}}
{{::ctrl.print(ctrl.idToItem[item.id].value)}}
')}]); \ No newline at end of file diff --git a/dist/form-viewer-material-tpls.min.js b/dist/form-viewer-material-tpls.min.js index c7976f5..f62378c 100644 --- a/dist/form-viewer-material-tpls.min.js +++ b/dist/form-viewer-material-tpls.min.js @@ -1 +1 @@ -angular.module("mwFormViewer").run(["$templateCache",function(e){e.put("mw-form-confirmation-page.html","
{{::ctrl.print(ctrl.confirmationMessage)}} Twoja odpowiedź została zapisana
Bład. Twoja odpowiedź nie została zapisana.
Zapisywanie odpowiedzi w trakcie.
"),e.put("mw-form-question.html",'
{{::ctrl.print(ctrl.question.text)}} *
{{::ctrl.print(answer.value)}}
Inna:
{{::ctrl.print(answer.value)}}
Inna:
{{::ctrl.print(answer.value)}}
{{::ctrl.print(row.label)}}
{{::ctrl.print(ctrl.question.unit)}}
{{ctrl.question.unit}} z wymaganych {{ctrl.question.quantity}} {{ctrl.question.unit}}
{{ctrl.questionResponse.answer}}
'),e.put("mw-form-viewer-content.html",'

{{ctrl.formData.name}}

{{ctrl.formData.description}}
Rozpocznij

{{ctrl.currentPage.name}}

{{pageElement.image.caption}}

WsteczDalej Submit
'),e.put("mw-form-viewer.html","
"),e.put("mw-priority-list.html",'
SortedAvailable
{{$index+1}}. {{::ctrl.print(ctrl.idToItem[item.id].value)}}
{{::ctrl.print(ctrl.idToItem[item.id].value)}}
')}]); \ No newline at end of file +angular.module("mwFormViewer").run(["$templateCache",function(e){e.put("mw-form-confirmation-page.html","
{{::ctrl.print(ctrl.confirmationMessage)}} Twoja odpowiedź została zapisana
Bład. Twoja odpowiedź nie została zapisana.
Zapisywanie odpowiedzi w trakcie.
"),e.put("mw-form-question.html",'
{{::ctrl.print(ctrl.question.text)}} *
{{::ctrl.print(answer.value)}}
Inna:
{{::ctrl.print(answer.value)}}
Inna:
{{::ctrl.print(answer.value)}}
{{::ctrl.print(row.label)}}
{{::ctrl.print(ctrl.question.unit)}}
{{ctrl.question.unit}} z wymaganych {{ctrl.question.quantity}} {{ctrl.question.unit}}
{{ctrl.questionResponse.answer}}
'),e.put("mw-form-viewer-content.html",'

{{ctrl.formData.name}}

{{ctrl.formData.description}}
Rozpocznij

{{ctrl.currentPage.name}}

{{pageElement.image.caption}}

WsteczDalej Submit
'),e.put("mw-form-viewer.html","
"),e.put("mw-priority-list.html",'
SortedAvailable
{{$index+1}}. {{::ctrl.print(ctrl.idToItem[item.id].value)}}
{{::ctrl.print(ctrl.idToItem[item.id].value)}}
')}]); \ No newline at end of file diff --git a/dist/form-viewer.min.js b/dist/form-viewer.min.js index abd0e86..a305771 100644 --- a/dist/form-viewer.min.js +++ b/dist/form-viewer.min.js @@ -1,5 +1,5 @@ angular.module("mwFormViewer",["ngSanitize","ui.bootstrap","ng-sortable","pascalprecht.translate"]); -angular.module("mwFormViewer").directive("mwPriorityList",function(){return{replace:!0,restrict:"AE",require:"^mwFormQuestion",scope:{question:"=",questionResponse:"=",readOnly:"=?",options:"=?"},templateUrl:"mw-priority-list.html",controllerAs:"ctrl",bindToController:!0,controller:function(){function i(i){if(i)for(var t=0;t0&&n.setCurrentPage(n.formData.pages[0])},n.resetPages=function(){n.prevPages=[],n.currentPage=null,n.nextPage=null,n.formSubmitted=!1,n.options.autoStart&&n.beginResponse()},n.resetPages(),n.goToPrevPage=function(){var e=n.prevPages.pop();n.setCurrentPage(e),n.updateNextPageBasedOnAllAnswers()},n.goToNextPage=function(){n.prevPages.push(n.currentPage),n.updateNextPageBasedOnAllAnswers(),n.setCurrentPage(n.nextPage)},n.updateNextPageBasedOnAllAnswers=function(){n.currentPage.elements.forEach(function(e){n.updateNextPageBasedOnPageElementAnswers(e)}),n.buttons.submitForm.visible=!n.nextPage,n.buttons.nextPage.visible=!!n.nextPage},n.updateNextPageBasedOnPageElementAnswers=function(e){var t=e.question;t&&t.pageFlowModifier&&t.offeredAnswers.forEach(function(e){e.pageFlow&&n.responseData[t.id].selectedAnswer==e.id&&(e.pageFlow.formSubmit?n.nextPage=null:e.pageFlow.page&&(n.nextPage=n.pageIdToPage[e.pageFlow.page.id]))})},n.onResponseChanged=function(e){n.setDefaultNextPage(),n.updateNextPageBasedOnAllAnswers()},n.api&&(n.api.reset=function(){for(var t in n.responseData)n.responseData.hasOwnProperty(t)&&delete n.responseData[t];n.buttons.submitForm.visible=!1,n.buttons.prevPage.visible=!1,n.buttons.nextPage.visible=!1,n.currentPage=null,e(n.resetPages,0)}),n.print=function(e){return n.templateData?t(e)(n.templateData):e}}],link:function(e,t,a){var n=e.ctrl;n.formStatus&&(n.formStatus.form=n.form)}}}); -angular.module("mwFormViewer").factory("FormQuestionId",function(){var e=0;return{next:function(){return++e}}}).directive("mwFormQuestion",function(){return{replace:!0,restrict:"AE",require:"^mwFormViewer",scope:{question:"=",questionResponse:"=",readOnly:"=?",options:"=?",onResponseChanged:"&?"},templateUrl:"mw-form-question.html",controllerAs:"ctrl",bindToController:!0,controller:["$timeout","FormQuestionId",function(e,s){var n=this;n.id=s.next(),"radio"==n.question.type?(n.questionResponse.selectedAnswer||(n.questionResponse.selectedAnswer=null),n.questionResponse.other&&(n.isOtherAnswer=!0)):"checkbox"==n.question.type?(n.questionResponse.selectedAnswers&&n.questionResponse.selectedAnswers.length?n.selectedAnswer=!0:n.questionResponse.selectedAnswers=[],n.questionResponse.other&&(n.isOtherAnswer=!0)):"grid"==n.question.type||"division"==n.question.type&&(n.computeDivisionSum=function(){n.divisionSum=0,n.question.divisionList.forEach(function(e){0==n.questionResponse[e.id]||n.questionResponse[e.id]?n.divisionSum+=n.questionResponse[e.id]:(n.questionResponse[e.id]=null,n.divisionSum+=0)})},n.computeDivisionSum()),n.isAnswerSelected=!1,n.selectedAnswerChanged=function(){delete n.questionResponse.other,n.isOtherAnswer=!1,n.answerChanged()},n.otherAnswerRadioChanged=function(){void 0,n.isOtherAnswer&&(n.questionResponse.selectedAnswer=null),n.answerChanged()},n.otherAnswerCheckboxChanged=function(){n.isOtherAnswer||delete n.questionResponse.other,n.selectedAnswer=n.questionResponse.selectedAnswers.length||n.isOtherAnswer?!0:null,n.answerChanged()},n.toggleSelectedAnswer=function(e){-1===n.questionResponse.selectedAnswers.indexOf(e.id)?n.questionResponse.selectedAnswers.push(e.id):n.questionResponse.selectedAnswers.splice(n.questionResponse.selectedAnswers.indexOf(e.id),1),n.selectedAnswer=n.questionResponse.selectedAnswers.length||n.isOtherAnswer?!0:null,n.answerChanged()},n.answerChanged=function(){n.onResponseChanged&&n.onResponseChanged()}}],link:function(e,s,n,o){var t=e.ctrl;t.print=o.print}}}); +angular.module("mwFormViewer").factory("FormQuestionId",function(){var e=0;return{next:function(){return++e}}}).directive("mwFormQuestion",function(){return{replace:!0,restrict:"AE",require:"^mwFormViewer",scope:{question:"=",questionResponse:"=",readOnly:"=?",options:"=?",onResponseChanged:"&?"},templateUrl:"mw-form-question.html",controllerAs:"ctrl",bindToController:!0,controller:["$timeout","FormQuestionId",function(e,n){var s=this;s.id=n.next(),"radio"==s.question.type?(s.questionResponse.selectedAnswer||(s.questionResponse.selectedAnswer=null),s.questionResponse.other&&(s.isOtherAnswer=!0)):"checkbox"==s.question.type?(s.questionResponse.selectedAnswers&&s.questionResponse.selectedAnswers.length?s.selectedAnswer=!0:s.questionResponse.selectedAnswers=[],s.questionResponse.other&&(s.isOtherAnswer=!0)):"grid"==s.question.type?s.question.grid.cellInputType||(s.question.grid.cellInputType="radio"):"division"==s.question.type&&(s.computeDivisionSum=function(){s.divisionSum=0,s.question.divisionList.forEach(function(e){0==s.questionResponse[e.id]||s.questionResponse[e.id]?s.divisionSum+=s.questionResponse[e.id]:(s.questionResponse[e.id]=null,s.divisionSum+=0)})},s.computeDivisionSum()),s.isAnswerSelected=!1,s.selectedAnswerChanged=function(){delete s.questionResponse.other,s.isOtherAnswer=!1,s.answerChanged()},s.otherAnswerRadioChanged=function(){void 0,s.isOtherAnswer&&(s.questionResponse.selectedAnswer=null),s.answerChanged()},s.otherAnswerCheckboxChanged=function(){s.isOtherAnswer||delete s.questionResponse.other,s.selectedAnswer=!(!s.questionResponse.selectedAnswers.length&&!s.isOtherAnswer)||null,s.answerChanged()},s.toggleSelectedAnswer=function(e){s.questionResponse.selectedAnswers.indexOf(e.id)===-1?s.questionResponse.selectedAnswers.push(e.id):s.questionResponse.selectedAnswers.splice(s.questionResponse.selectedAnswers.indexOf(e.id),1),s.selectedAnswer=!(!s.questionResponse.selectedAnswers.length&&!s.isOtherAnswer)||null,s.answerChanged()},s.answerChanged=function(){s.onResponseChanged&&s.onResponseChanged()}}],link:function(e,n,s,o){var t=e.ctrl;t.print=o.print}}}); angular.module("mwFormViewer").directive("mwFormConfirmationPage",function(){return{replace:!0,restrict:"AE",require:"^mwFormViewer",scope:{submitStatus:"=",confirmationMessage:"=",readOnly:"=?"},templateUrl:"mw-form-confirmation-page.html",controllerAs:"ctrl",bindToController:!0,controller:function(){},link:function(r,e,t,n){var o=r.ctrl;o.print=n.print}}}); \ No newline at end of file diff --git a/dist/i18n/en/angular-surveys.json b/dist/i18n/en/angular-surveys.json index 4a726bf..b57262a 100644 --- a/dist/i18n/en/angular-surveys.json +++ b/dist/i18n/en/angular-surveys.json @@ -1 +1 @@ -{"mwForm":{"form":{"name":"Form name","name.placeholder":"Form title","description":"Description"},"buttons":{"addPage":"Add page","moveDown":"Move down","moveUp":"Move up","removePage":"Remove page","remove":"Remove","addElement":"Add element","questionReady":"Ready","next":"Next","back":"Back","submit":"Submit","begin":"Begin","fold":"Fold","unfold":"Unfold","edit":"Edit","clone":"Clone","view":"View"},"page":{"tab":{"heading":"Page {{page}} of {{allPages}}"},"elements":{"empty":"Empty page"},"pageWithNameCheckbox":"named","name":"Page name"},"pageFlow":{"afterPage":"After page {{page}}:","afterQuestionAnswer":"Go to page based on answer","goToPage":"Go to page {{page.number}}","goToNextPage":"Continue to next page","submitForm":"Submit form"},"elements":{"question":"Question","image":"Image","paragraph":"Paragraph"},"question":{"types":{"text":{"name":"Short text"},"textarea":{"name":"Long text"},"radio":{"name":"Radio"},"select":{"name":"Select"},"checkbox":{"name":"Checkboxes"},"grid":{"name":"Grid"},"priority":{"name":"Priority"},"division":{"name":"Division"},"number":{"name":"Number"},"date":{"name":"Date"},"datetime":{"name":"Datetime"},"time":{"name":"Time"},"email":{"name":"Email"},"range":{"name":"Range"},"url":{"name":"URL"}},"text":"Question text","type":"Question type","required":"Required","preview":{"text":"Short answer text","textarea":"Long answer text","otherAnswer":"Other"},"division":{"quantity":"Quantity","unit":"Unit label","assignedSumLabel":"Assigned","fromRequiredLabel":"from required"},"priority":{"sorted":"Sorted","available":"Available","clickToAddItem":"Click to add item"},"grid":{"rowLabel":"Row {{row}}","clickToAddRow":"Click to add row","columnLabel":"Column {{col}}","clickToAddColumn":"Click to add column"},"range":{"from":"Range from","to":"to"},"number":{"min":"Min","max":"Max"},"orLabel":"or ","otherLabel":"Other: ","userAnswer":"User answer","buttons":{"addOption":"Click to add option","addOther":"Add 'Other'"}},"image":{"selectImageButton":"Select image","caption":"Image caption"},"paragraph":{"placeholder":"Enter paragraph text"},"confirmationPage":{"title":"Confirmation page","customMessage":"Custom confirmation message","defaultMessage":"Your response has been recorded","errorMessage":"Error! Your response has not been recorded","pendingMessage":"Your response is being saved."}}} \ No newline at end of file +{"mwForm":{"form":{"name":"Form name","name.placeholder":"Form title","description":"Description"},"buttons":{"addPage":"Add page","moveDown":"Move down","moveUp":"Move up","removePage":"Remove page","remove":"Remove","addElement":"Add element","questionReady":"Ready","next":"Next","back":"Back","submit":"Submit","begin":"Begin","fold":"Fold","unfold":"Unfold","edit":"Edit","clone":"Clone","view":"View"},"page":{"tab":{"heading":"Page {{page}} of {{allPages}}"},"elements":{"empty":"Empty page"},"pageWithNameCheckbox":"named","name":"Page name"},"pageFlow":{"afterPage":"After page {{page}}:","afterQuestionAnswer":"Go to page based on answer","goToPage":"Go to page {{page.number}}","goToNextPage":"Continue to next page","submitForm":"Submit form"},"elements":{"question":"Question","image":"Image","paragraph":"Paragraph"},"question":{"types":{"text":{"name":"Short text"},"textarea":{"name":"Long text"},"radio":{"name":"Radio"},"select":{"name":"Select"},"checkbox":{"name":"Checkboxes"},"grid":{"name":"Grid"},"priority":{"name":"Priority"},"division":{"name":"Division"},"number":{"name":"Number"},"date":{"name":"Date"},"datetime":{"name":"Datetime"},"time":{"name":"Time"},"email":{"name":"Email"},"range":{"name":"Range"},"url":{"name":"URL"}},"text":"Question text","type":"Question type","required":"Required","preview":{"text":"Short answer text","textarea":"Long answer text","otherAnswer":"Other"},"division":{"quantity":"Quantity","unit":"Unit label","assignedSumLabel":"Assigned","fromRequiredLabel":"from required"},"priority":{"sorted":"Sorted","available":"Available","clickToAddItem":"Click to add item"},"grid":{"cellInputType":"Cell input type","cellInputTypes":{"radio":"Radio","checkbox":"Checkbox","text":"Text","number":"Number","date":"Date","time":"Time"},"rowLabel":"Row {{row}}","clickToAddRow":"Click to add row","columnLabel":"Column {{col}}","clickToAddColumn":"Click to add column"},"range":{"from":"Range from","to":"to"},"number":{"min":"Min","max":"Max"},"orLabel":"or ","otherLabel":"Other: ","userAnswer":"User answer","buttons":{"addOption":"Click to add option","addOther":"Add 'Other'"}},"image":{"selectImageButton":"Select image","caption":"Image caption"},"paragraph":{"placeholder":"Enter paragraph text"},"confirmationPage":{"title":"Confirmation page","customMessage":"Custom confirmation message","defaultMessage":"Your response has been recorded","errorMessage":"Error! Your response has not been recorded","pendingMessage":"Your response is being saved."}}} \ No newline at end of file diff --git a/dist/i18n/es/angular-surveys.json b/dist/i18n/es/angular-surveys.json index c20ad87..7fcd6f8 100644 --- a/dist/i18n/es/angular-surveys.json +++ b/dist/i18n/es/angular-surveys.json @@ -1 +1 @@ -{"mwForm":{"form":{"name":"Nombre del formulario","name.placeholder":"Título del formulario","description":"Descripción"},"buttons":{"addPage":"Agregar página","moveDown":"Bajar","moveUp":"Subir","removePage":"Remover página","remove":"Eliminar","addElement":"Agregar elemento","questionReady":"Listo","next":"Siguiente","back":"Atras","submit":"Enviar","begin":"Comenzar","fold":"Colapsar","unfold":"Expander","edit":"Editar","clone":"Duplicar","view":"Ver"},"page":{"tab":{"heading":"Página {{page}} de {{allPages}}"},"elements":{"empty":"Página vacia"},"pageWithNameCheckbox":"nombrar","name":"Nombre de página"},"pageFlow":{"afterPage":"Despues de página {{page}}:","afterQuestionAnswer":"Ir a página basado en respuesta","goToPage":"Ir a página {{page.number}}","goToNextPage":"Continuar a la siguiente página","submitForm":"Enviar formulario"},"elements":{"question":"Pregunta","image":"Imagen","paragraph":"Párrafo"},"question":{"types":{"text":{"name":"Texto corto"},"textarea":{"name":"Texto largo"},"radio":{"name":"Radio"},"select":{"name":"Select"},"checkbox":{"name":"Checkboxes"},"grid":{"name":"Grid"},"priority":{"name":"Prioridad"},"division":{"name":"Division"},"number":{"name":"Número"},"date":{"name":"Fecha"},"datetime":{"name":"Fecha y hora"},"time":{"name":"Hora"},"email":{"name":"Email"},"range":{"name":"Rango"},"url":{"name":"URL"}},"text":"Texto de pregunta","type":"Tipo de pregunta","required":"Requerida","preview":{"text":"Texto corto respuesta","textarea":"Texto largo respuesta","otherAnswer":"Otra"},"division":{"quantity":"Cantidad","unit":"Etiqueta de unidad","assignedSumLabel":"Asignado","fromRequiredLabel":"de lo requerido:"},"priority":{"sorted":"Ordenados","available":"Disponibles","clickToAddItem":"Click para agregar ítem"},"grid":{"rowLabel":"Fila {{row}}","clickToAddRow":"Click para agregar fila","columnLabel":"Columna {{col}}","clickToAddColumn":"Click para agregar columna"},"range":{"from":"Rango desde","to":"hasta"},"number":{"min":"Min","max":"Max"},"orLabel":"o ","otherLabel":"Otra: ","userAnswer":"Respuesta del usuario","buttons":{"addOption":"Click para agregar opción","addOther":"Agregar 'Otra'"}},"image":{"selectImageButton":"Seleccionar imagen","caption":"Image caption"},"paragraph":{"placeholder":"Digite texto de párrafo"},"confirmationPage":{"title":"Página de confirmación","customMessage":"Mensaje de confirmación personalizada","defaultMessage":"Tus respuestas han sido guardadas","errorMessage":"Error! Tus respuestas no han sido guardadas","pendingMessage":"Tus respuestas estan siendo guardadas."}}} \ No newline at end of file +{"mwForm":{"form":{"name":"Nombre del formulario","name.placeholder":"Título del formulario","description":"Descripción"},"buttons":{"addPage":"Agregar página","moveDown":"Bajar","moveUp":"Subir","removePage":"Remover página","remove":"Eliminar","addElement":"Agregar elemento","questionReady":"Listo","next":"Siguiente","back":"Atras","submit":"Enviar","begin":"Comenzar","fold":"Colapsar","unfold":"Expander","edit":"Editar","clone":"Duplicar","view":"Ver"},"page":{"tab":{"heading":"Página {{page}} de {{allPages}}"},"elements":{"empty":"Página vacia"},"pageWithNameCheckbox":"nombrar","name":"Nombre de página"},"pageFlow":{"afterPage":"Despues de página {{page}}:","afterQuestionAnswer":"Ir a página basado en respuesta","goToPage":"Ir a página {{page.number}}","goToNextPage":"Continuar a la siguiente página","submitForm":"Enviar formulario"},"elements":{"question":"Pregunta","image":"Imagen","paragraph":"Párrafo"},"question":{"types":{"text":{"name":"Texto corto"},"textarea":{"name":"Texto largo"},"radio":{"name":"Radio"},"select":{"name":"Select"},"checkbox":{"name":"Checkboxes"},"grid":{"name":"Grid"},"priority":{"name":"Prioridad"},"division":{"name":"Division"},"number":{"name":"Número"},"date":{"name":"Fecha"},"datetime":{"name":"Fecha y hora"},"time":{"name":"Hora"},"email":{"name":"Email"},"range":{"name":"Rango"},"url":{"name":"URL"}},"text":"Texto de pregunta","type":"Tipo de pregunta","required":"Requerida","preview":{"text":"Texto corto respuesta","textarea":"Texto largo respuesta","otherAnswer":"Otra"},"division":{"quantity":"Cantidad","unit":"Etiqueta de unidad","assignedSumLabel":"Asignado","fromRequiredLabel":"de lo requerido:"},"priority":{"sorted":"Ordenados","available":"Disponibles","clickToAddItem":"Click para agregar ítem"},"grid":{"cellInputType":"Cell input type","cellInputTypes":{"radio":"Radio","checkbox":"Checkbox","text":"Texto","number":"Número","date":"Fecha","time":"Hora"},"rowLabel":"Fila {{row}}","clickToAddRow":"Click para agregar fila","columnLabel":"Columna {{col}}","clickToAddColumn":"Click para agregar columna"},"range":{"from":"Rango desde","to":"hasta"},"number":{"min":"Min","max":"Max"},"orLabel":"o ","otherLabel":"Otra: ","userAnswer":"Respuesta del usuario","buttons":{"addOption":"Click para agregar opción","addOther":"Agregar 'Otra'"}},"image":{"selectImageButton":"Seleccionar imagen","caption":"Image caption"},"paragraph":{"placeholder":"Digite texto de párrafo"},"confirmationPage":{"title":"Página de confirmación","customMessage":"Mensaje de confirmación personalizada","defaultMessage":"Tus respuestas han sido guardadas","errorMessage":"Error! Tus respuestas no han sido guardadas","pendingMessage":"Tus respuestas estan siendo guardadas."}}} \ No newline at end of file diff --git a/dist/i18n/pl/angular-surveys.json b/dist/i18n/pl/angular-surveys.json index 56a9f1f..35951c3 100644 --- a/dist/i18n/pl/angular-surveys.json +++ b/dist/i18n/pl/angular-surveys.json @@ -1 +1 @@ -{"mwForm":{"form":{"name":"Nazwa ankiety","name.placeholder":"Podaj nazwę ankiety","description":"Opis"},"buttons":{"addPage":"Dodaj stronę","moveDown":"Przenieś w dół","moveUp":"Przenieś w górę","removePage":"Usuń stronę","remove":"Usuń","addElement":"Dodaj element","questionReady":"Gotowe","next":"Dalej","back":"Wstecz","submit":"Prześlij","begin":"Rozpocznij","fold":"Zwiń","unfold":"Rozwiń","edit":"Edytuj","clone":"Klonuj","view":"Wyświetl"},"page":{"tab":{"heading":"Strona {{page}} z {{allPages}}"},"elements":{"empty":"Brak elementów"},"pageWithNameCheckbox":"nazwana","name":"Nazwa strony"},"pageFlow":{"afterPage":"Po stronie {{page}}","afterQuestionAnswer":"Przejdź do strony w oparciu o odpowiedź","goToPage":"Przejdź do strony numer {{page.number}}","goToNextPage":"Przejdz do następnej strony","submitForm":"Prześlij formularz"},"elements":{"question":"Pytanie/Polecenie","image":"Obraz","paragraph":"Paragraf"},"question":{"types":{"text":{"name":"Tekst"},"textarea":{"name":"Długi tekst"},"radio":{"name":"Jednokrotny wybór"},"select":{"name":"Lista rozwijana"},"checkbox":{"name":"Wielokrotny wybór"},"grid":{"name":"Siatka"},"priority":{"name":"Lista priorytetowa"},"division":{"name":"Podział"},"number":{"name":"Liczba"},"date":{"name":"Data"},"datetime":{"name":"Data i godzina"},"time":{"name":"Godzina"},"email":{"name":"Email"},"range":{"name":"Zakres"},"url":{"name":"Adres URL"}},"text":"Treść pytania","type":"Typ pytania","required":"Pytanie wymagane","preview":{"text":"Pole na wpisanie odpowiedzi","textarea":"Pole na wpisanie odpowiedzi","otherAnswer":"Inna"},"division":{"quantity":"Ilość","unit":"Etykieta jednostki","assignedSumLabel":"Przydzielono","fromRequiredLabel":"z wymaganych"},"priority":{"sorted":"Uszeregowane","available":"Pozostałe","clickToAddItem":"Kliknij aby dodać pozycję"},"grid":{"rowLabel":"Etykieta wiersza {{row}}","clickToAddRow":"Kliknij aby dodać wiersz","columnLabel":"Etykieta kolumny {{col}}","clickToAddColumn":"Kliknij aby dodać kolumnę"},"range":{"from":"Zakres od","to":"do"},"number":{"min":"Min","max":"Max"},"orLabel":"lub ","otherLabel":"Inna: ","userAnswer":"Odpowiedź użytkownika","buttons":{"addOption":"Kliknij aby dodać opcję","addOther":"Dodaj \"Inne\""}},"image":{"selectImageButton":"Wybierz obraz","caption":"Podpis"},"paragraph":{"placeholder":"Wpisz treść paragrafu"},"confirmationPage":{"title":"Strona potwierdzenia","customMessage":"Niestandardowa wiadomość z potwierdzeniem","defaultMessage":"Twoja odpowiedź została zapisana","errorMessage":"Błąd. Twoja odpowiedź nie została zapisana.","pendingMessage":"Zapisywanie odpowiedzi w trakcie."}}} \ No newline at end of file +{"mwForm":{"form":{"name":"Nazwa ankiety","name.placeholder":"Podaj nazwę ankiety","description":"Opis"},"buttons":{"addPage":"Dodaj stronę","moveDown":"Przenieś w dół","moveUp":"Przenieś w górę","removePage":"Usuń stronę","remove":"Usuń","addElement":"Dodaj element","questionReady":"Gotowe","next":"Dalej","back":"Wstecz","submit":"Prześlij","begin":"Rozpocznij","fold":"Zwiń","unfold":"Rozwiń","edit":"Edytuj","clone":"Klonuj","view":"Wyświetl"},"page":{"tab":{"heading":"Strona {{page}} z {{allPages}}"},"elements":{"empty":"Brak elementów"},"pageWithNameCheckbox":"nazwana","name":"Nazwa strony"},"pageFlow":{"afterPage":"Po stronie {{page}}","afterQuestionAnswer":"Przejdź do strony w oparciu o odpowiedź","goToPage":"Przejdź do strony numer {{page.number}}","goToNextPage":"Przejdz do następnej strony","submitForm":"Prześlij formularz"},"elements":{"question":"Pytanie/Polecenie","image":"Obraz","paragraph":"Paragraf"},"question":{"types":{"text":{"name":"Tekst"},"textarea":{"name":"Długi tekst"},"radio":{"name":"Jednokrotny wybór"},"select":{"name":"Lista rozwijana"},"checkbox":{"name":"Wielokrotny wybór"},"grid":{"name":"Siatka"},"priority":{"name":"Lista priorytetowa"},"division":{"name":"Podział"},"number":{"name":"Liczba"},"date":{"name":"Data"},"datetime":{"name":"Data i godzina"},"time":{"name":"Godzina"},"email":{"name":"Email"},"range":{"name":"Zakres"},"url":{"name":"Adres URL"}},"text":"Treść pytania","type":"Typ pytania","required":"Pytanie wymagane","preview":{"text":"Pole na wpisanie odpowiedzi","textarea":"Pole na wpisanie odpowiedzi","otherAnswer":"Inna"},"division":{"quantity":"Ilość","unit":"Etykieta jednostki","assignedSumLabel":"Przydzielono","fromRequiredLabel":"z wymaganych"},"priority":{"sorted":"Uszeregowane","available":"Pozostałe","clickToAddItem":"Kliknij aby dodać pozycję"},"grid":{"cellInputType":"Typ komórki","cellInputTypes":{"radio":"Radio","checkbox":"Checkbox","text":"Tekst","number":"Liczba","date":"Data","time":"Godzina"},"rowLabel":"Etykieta wiersza {{row}}","clickToAddRow":"Kliknij aby dodać wiersz","columnLabel":"Etykieta kolumny {{col}}","clickToAddColumn":"Kliknij aby dodać kolumnę"},"range":{"from":"Zakres od","to":"do"},"number":{"min":"Min","max":"Max"},"orLabel":"lub ","otherLabel":"Inna: ","userAnswer":"Odpowiedź użytkownika","buttons":{"addOption":"Kliknij aby dodać opcję","addOther":"Dodaj \"Inne\""}},"image":{"selectImageButton":"Wybierz obraz","caption":"Podpis"},"paragraph":{"placeholder":"Wpisz treść paragrafu"},"confirmationPage":{"title":"Strona potwierdzenia","customMessage":"Niestandardowa wiadomość z potwierdzeniem","defaultMessage":"Twoja odpowiedź została zapisana","errorMessage":"Błąd. Twoja odpowiedź nie została zapisana.","pendingMessage":"Zapisywanie odpowiedzi w trakcie."}}} \ No newline at end of file diff --git a/i18n/en/angular-surveys.json b/i18n/en/angular-surveys.json index e5f6aad..c2a6db8 100644 --- a/i18n/en/angular-surveys.json +++ b/i18n/en/angular-surveys.json @@ -116,6 +116,15 @@ "clickToAddItem": "Click to add item" }, "grid":{ + "cellInputType": "Cell input type", + "cellInputTypes":{ + "radio": "Radio", + "checkbox": "Checkbox", + "text": "Text", + "number": "Number", + "date": "Date", + "time": "Time" + }, "rowLabel": "Row {{row}}", "clickToAddRow": "Click to add row", "columnLabel": "Column {{col}}", diff --git a/i18n/es/angular-surveys.json b/i18n/es/angular-surveys.json index 8d9a297..cbfd49c 100644 --- a/i18n/es/angular-surveys.json +++ b/i18n/es/angular-surveys.json @@ -113,6 +113,16 @@ "clickToAddItem": "Click para agregar ítem" }, "grid": { + "cellInputType": "Cell input type", + "cellInputTypes":{ + "radio": "Radio", + "checkbox": "Checkbox", + "text": "Texto", + "number": "Número", + "date": "Fecha", + "time": "Hora" + + }, "rowLabel": "Fila {{row}}", "clickToAddRow": "Click para agregar fila", "columnLabel": "Columna {{col}}", diff --git a/i18n/pl/angular-surveys.json b/i18n/pl/angular-surveys.json index 8c08c9d..09dd538 100644 --- a/i18n/pl/angular-surveys.json +++ b/i18n/pl/angular-surveys.json @@ -116,6 +116,15 @@ "clickToAddItem": "Kliknij aby dodać pozycję" }, "grid":{ + "cellInputType": "Typ komórki", + "cellInputTypes":{ + "radio": "Radio", + "checkbox": "Checkbox", + "text": "Tekst", + "number": "Liczba", + "date": "Data", + "time": "Godzina" + }, "rowLabel": "Etykieta wiersza {{row}}", "clickToAddRow": "Kliknij aby dodać wiersz", "columnLabel": "Etykieta kolumny {{col}}", diff --git a/src/builder/form-builder-options.service.js b/src/builder/form-builder-options.service.js index 740d128..9ee5b41 100644 --- a/src/builder/form-builder-options.service.js +++ b/src/builder/form-builder-options.service.js @@ -1,6 +1,7 @@ angular.module('mwFormBuilder') .constant('MW_QUESTION_TYPES', ['text', 'textarea', 'radio', 'checkbox', 'select', 'grid', 'priority', 'division', 'number', 'date', 'time', 'email', 'range', 'url']) .constant('MW_ELEMENT_TYPES', ['question', 'image', 'paragraph']) + .constant('MW_GRID_CELL_INPUT_TYPES', ['radio', 'checkbox', 'text', 'number', 'date', 'time']) .factory('mwFormBuilderOptions', function mwFormBuilderOptionsFactory(MW_ELEMENT_TYPES, MW_QUESTION_TYPES){ var defaultElementButtonOptions={ diff --git a/src/builder/question-grid-builder.directive.js b/src/builder/question-grid-builder.directive.js index 77ba056..91132cb 100644 --- a/src/builder/question-grid-builder.directive.js +++ b/src/builder/question-grid-builder.directive.js @@ -14,8 +14,10 @@ angular.module('mwFormBuilder').directive('mwQuestionGridBuilder', function () { templateUrl: 'mw-question-grid-builder.html', controllerAs: 'ctrl', bindToController: true, - controller: function(mwFormUuid){ + controller: function(mwFormUuid, MW_GRID_CELL_INPUT_TYPES){ var ctrl = this; + ctrl.cellInputTypes = MW_GRID_CELL_INPUT_TYPES; + ctrl.isNewInput = {}; ctrl.addNewRow=function(noFocus){ @@ -47,6 +49,7 @@ angular.module('mwFormBuilder').directive('mwQuestionGridBuilder', function () { if(!ctrl.question.grid){ + ctrl.question.grid = { rows:[], cols:[] @@ -55,6 +58,9 @@ angular.module('mwFormBuilder').directive('mwQuestionGridBuilder', function () { ctrl.addNewCol(true); } + if(!ctrl.question.grid.cellInputType){ + ctrl.question.grid.cellInputType = ctrl.cellInputTypes[0]; + } diff --git a/src/builder/templates/bootstrap/mw-form-question-builder.html b/src/builder/templates/bootstrap/mw-form-question-builder.html index 8662827..b48cbe8 100644 --- a/src/builder/templates/bootstrap/mw-form-question-builder.html +++ b/src/builder/templates/bootstrap/mw-form-question-builder.html @@ -172,7 +172,9 @@
- +
@@ -192,8 +194,10 @@ {{row.label}} - - + + + + diff --git a/src/builder/templates/bootstrap/mw-question-grid-builder.html b/src/builder/templates/bootstrap/mw-question-grid-builder.html index 76b8267..a3afb5c 100644 --- a/src/builder/templates/bootstrap/mw-question-grid-builder.html +++ b/src/builder/templates/bootstrap/mw-question-grid-builder.html @@ -1,4 +1,12 @@
+
+
+ +
+ +
+
+
diff --git a/src/builder/templates/material/mw-form-question-builder.html b/src/builder/templates/material/mw-form-question-builder.html index cc554ea..12adff5 100644 --- a/src/builder/templates/material/mw-form-question-builder.html +++ b/src/builder/templates/material/mw-form-question-builder.html @@ -247,10 +247,17 @@ {{row.label}} - - + + +
+ +
+ + + + diff --git a/src/builder/templates/material/mw-question-grid-builder.html b/src/builder/templates/material/mw-question-grid-builder.html index 295b5bb..fab1067 100644 --- a/src/builder/templates/material/mw-question-grid-builder.html +++ b/src/builder/templates/material/mw-question-grid-builder.html @@ -1,5 +1,21 @@
-
+
+ +
+
+ + + + + {{'mwForm.question.grid.cellInputTypes.'+opt|translate}} + + + + +
+ +
+
diff --git a/src/utils/form-response-utils.service.js b/src/utils/form-response-utils.service.js index bbcea46..db6f969 100644 --- a/src/utils/form-response-utils.service.js +++ b/src/utils/form-response-utils.service.js @@ -91,10 +91,41 @@ angular.module('mwFormUtils.responseUtils', []) }; service.$extractResponseForGridQuestion = function (question, questionResponse) { - var result = []; + if (!question.grid || !question.grid.rows) { return result; } + + if(question.grid.cellInputType == 'radio'){ + return service.$extractResponseForRadioGridQuestion(question, questionResponse); + } + var result = []; + question.grid.rows.forEach(function (row) { + question.grid.cols.forEach(function (col) { + var res = { + row: { + id: row.id, + label: row.label + }, + col: { + id: col.id, + label: col.label + }, + value: null + }; + + if(questionResponse.hasOwnProperty(row.id) && questionResponse[row.id].hasOwnProperty(col.id)){ + res.value = questionResponse[row.id][col.id]; + } + + result.push(res); + }); + }); + return result; + }; + + service.$extractResponseForRadioGridQuestion= function (question, questionResponse) { + var result = []; var colById = service.$getObjectByIdMap(question.grid.cols); question.grid.rows.forEach(function (row) { var selectedColId = questionResponse[row.id]; @@ -103,6 +134,8 @@ angular.module('mwFormUtils.responseUtils', []) selectedCol = colById[selectedColId]; } + + var rowResponse = { row: { id: row.id, @@ -204,7 +237,7 @@ angular.module('mwFormUtils.responseUtils', []) }; //Returns a formatted string with an optional question number and the text of the question. - service.$$getHeader = function (number, questionText, subQuestionNumber, subQuestionText, withQuestionNumber) { + service.$$getHeader = function (number, questionText, subQuestionNumbers, subQuestionTexts, withQuestionNumber) { var result = ''; if (withQuestionNumber) { @@ -212,9 +245,17 @@ angular.module('mwFormUtils.responseUtils', []) result += number + '.'; } - if (subQuestionNumber || subQuestionNumber === 0) { - result += subQuestionNumber + '.'; + if(subQuestionNumbers!==null && subQuestionNumbers!==undefined){ + if(!Array.isArray(subQuestionNumbers)){ + subQuestionNumbers = [subQuestionNumbers] + } + + + subQuestionNumbers.forEach(function(num){ + result += num + '.'; + }); } + if (result.length) { result += ' '; } @@ -223,9 +264,16 @@ angular.module('mwFormUtils.responseUtils', []) result += questionText; - if (subQuestionText) { - result += ' [' + subQuestionText + ']'; + if(subQuestionTexts===null || subQuestionTexts===undefined){ + return result; + } + + if(!Array.isArray(subQuestionTexts)){ + subQuestionTexts = [subQuestionTexts] } + subQuestionTexts.forEach(function(txt){ + result += ' [' + txt + ']'; + }); return result; }; @@ -251,10 +299,21 @@ angular.module('mwFormUtils.responseUtils', []) if (!question.grid) { return; } - question.grid.rows.forEach(function (row) { - result.push(service.$$getHeader(questionNumber, question.text, subIndex, row.label, withQuestionNumbers)); - subIndex++; - }); + if(question.grid.cellInputType=='radio'){ + question.grid.rows.forEach(function (row) { + result.push(service.$$getHeader(questionNumber, question.text, subIndex, row.label, withQuestionNumbers)); + subIndex++; + }); + }else{ + question.grid.rows.forEach(function (row, rowIndex) { + + question.grid.cols.forEach(function (col, colIndex) { + result.push(service.$$getHeader(questionNumber, question.text, [rowIndex+1, colIndex+1], [row.label, col.label], withQuestionNumbers)); + subIndex++; + }); + }); + } + } else if (question.type == 'priority') { if (!question.priorityList) { @@ -347,13 +406,24 @@ angular.module('mwFormUtils.responseUtils', []) continue; } if (!response) { - question.grid.rows.forEach(function () { result.push("") }); + if(question.grid.cellInputType=='radio'){ + question.grid.rows.forEach(function () { result.push("") }); + }else{ + question.grid.rows.forEach(function () { question.grid.cols.forEach(function () { result.push("") }); }); + } + continue; } - response.forEach(function (entry) { - result.push(entry.col ? entry.col.label : ""); + if(question.grid.cellInputType=='radio'){ + response.forEach(function (entry) { + result.push(entry.col ? entry.col.label : ""); + }); + }else{ + response.forEach(function (entry) { + result.push(entry.value); + }); + } - }); } else if (question.type == 'priority') { if (!question.priorityList) { diff --git a/src/viewer/form-question.directive.js b/src/viewer/form-question.directive.js index 8b0b684..3d19aab 100644 --- a/src/viewer/form-question.directive.js +++ b/src/viewer/form-question.directive.js @@ -48,6 +48,9 @@ angular.module('mwFormViewer').factory("FormQuestionId", function(){ }else if(ctrl.question.type=='grid'){ + if(!ctrl.question.grid.cellInputType){ + ctrl.question.grid.cellInputType = "radio"; + } //if(ctrl.questionResponse.selectedAnswers){ // //}else{ diff --git a/src/viewer/templates/bootstrap/mw-form-question.html b/src/viewer/templates/bootstrap/mw-form-question.html index 5b49b93..72e3d01 100644 --- a/src/viewer/templates/bootstrap/mw-form-question.html +++ b/src/viewer/templates/bootstrap/mw-form-question.html @@ -67,11 +67,14 @@ {{::ctrl.print(row.label)}} - - + + + + +
diff --git a/src/viewer/templates/material/mw-form-question.html b/src/viewer/templates/material/mw-form-question.html index d8654b2..3954269 100644 --- a/src/viewer/templates/material/mw-form-question.html +++ b/src/viewer/templates/material/mw-form-question.html @@ -82,10 +82,17 @@ {{::ctrl.print(row.label)}} - - + + +
+ +
+ + + +