diff --git a/dist/form-builder.min.js b/dist/form-builder.min.js index 77ae402..68bbc37 100644 --- a/dist/form-builder.min.js +++ b/dist/form-builder.min.js @@ -1,6 +1,6 @@ angular.module("mwFormBuilder",["ngSanitize","ui.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()}}); -angular.module("mwFormBuilder").run(["$templateCache",function(e){e.put("mw-form-builder.html",'
'),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",'


{{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",'
')}]); +angular.module("mwFormBuilder").run(["$templateCache",function(e){e.put("mw-form-builder.html",'
'),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",'


{{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",'
')}]); angular.module("mwFormBuilder").directive("mwQuestionPriorityListBuilder",function(){return{replace:!0,restrict:"AE",require:"^mwFormQuestionBuilder",scope:{question:"=",readOnly:"=?",options:"=?"},templateUrl:"mw-question-priority-list-builder.html",controllerAs:"ctrl",bindToController:!0,controller:["mwFormUuid",function(i){function e(i){if(i)for(var e=0;e=0&&a(l.formPage.elements,n,t),o()},l.addQuestion=function(){l.addElement("question")},l.addImage=function(){l.addElement("image")},l.addParagraph=function(){l.addElement("paragraph")},l.isElementActive=function(e){return l.activeElement==e},l.selectElement=function(e){l.activeElement=e},l.onElementReady=function(){e(function(){l.activeElement=null})},l.hoverIn=function(){l.hoverEdit=!0},l.hoverOut=function(){l.hoverEdit=!1},l.updateElementsOrderNo=o}],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.onImageSelection=t.onImageSelection}}}); +angular.module("mwFormBuilder").directive("mwFormPageElementBuilder",function(){return{replace:!0,restrict:"AE",require:"^mwFormPageBuilder",scope:{pageElement:"=",formObject:"=",isActive:"=",isFirst:"=",isLast:"=",onReady:"&",readOnly:"=?",options:"=?"},templateUrl:"mw-form-page-element-builder.html",controllerAs:"ctrl",bindToController:!0,controller:["mwFormUuid",function(e){var t=this;"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.onImageSelection=l.onImageSelection}}}); +angular.module("mwFormBuilder").directive("mwFormPageBuilder",function(){return{replace:!0,restrict:"AE",require:"^mwFormBuilder",scope:{formPage:"=",formObject:"=",isFirst:"=",isLast:"=",readOnly:"=?",options:"=?"},templateUrl:"mw-form-page-builder.html",controllerAs:"ctrl",bindToController:!0,controller:["$timeout","mwFormUuid",function(e,n){function o(){for(var e=0;e=0)&&(m.push(e),!e!==Object(e))){if(Array.isArray(e))return void e.forEach(r);for(var t in e)e.hasOwnProperty(t)&&r(e[t]);if(e.hasOwnProperty("id")){var i=n.get(),a=e.id;void 0,e.id=i}}}function i(e,o){return{id:n.get(),orderNo:o,type:e}}function a(e,n,o){var t=e[n];e.splice(n,1),e.splice(o,0,t)}var l=this;l.hoverEdit=!1,l.formPage.namedPage=!!l.formPage.name,l.isFolded=!1,l.unfold=function(){l.isFolded=!1},l.fold=function(){l.isFolded=!0},t(),l.sortableConfig={disabled:l.readOnly,placeholder:"beingDragged",handle:".inactive",connectWith:".page-element-list",stop:function(e,n){o()}},l.activeElement=null,l.addElement=function(e){e||(e="question");var n=i(e,l.formPage.elements.length+1);l.activeElement=n,l.formPage.elements.push(n)},l.cloneElement=function(e,n){var o=l.formPage.elements.indexOf(e),t={};angular.copy(e,t),n&&(l.activeElement=t),r(t,!0),l.formPage.elements.splice(o,0,t)};var m=[];l.removeElement=function(e){var n=l.formPage.elements.indexOf(e);l.formPage.elements.splice(n,1)},l.moveDownElement=function(e){var n=l.formPage.elements.indexOf(e),t=n+1;t=0&&a(l.formPage.elements,n,t),o()},l.addQuestion=function(){l.addElement("question")},l.addImage=function(){l.addElement("image")},l.addParagraph=function(){l.addElement("paragraph")},l.isElementActive=function(e){return l.activeElement==e},l.selectElement=function(e){l.activeElement=e},l.onElementReady=function(){e(function(){l.activeElement=null})},l.hoverIn=function(){l.hoverEdit=!0},l.hoverOut=function(){l.hoverEdit=!1},l.updateElementsOrderNo=o}],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.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:"=?",options:"=?",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:"=?",options:"=?"},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,t){}}}); angular.module("mwFormBuilder").directive("mwFormBuilder",function(){return{replace:!0,restrict:"AE",scope:{formData:"=",readOnly:"=?",options:"=?",formStatus:"=?",confirm:"=",onImageSelection:"&",api:"=?"},templateUrl:"mw-form-builder.html",controllerAs:"ctrl",bindToController:!0,controller:["mwFormUuid",function(a){function e(e){var o=null;return t.possiblePageFlow&&(o=t.possiblePageFlow[0]),{id:a.get(),number:e,name:null,description:null,pageFlow:o,elements:[]}}function o(){for(var a=0;a=0&&r(t.formData.pages,e,n),o()},t.removePage=function(a){var e=t.formData.pages.indexOf(a);t.formData.pages.splice(e,1),o()},t.api&&(t.api.reset=function(){for(var a in t.formData)t.formData.hasOwnProperty(a)&&"pages"!=a&&delete t.formData[a];t.formData.pages.length=0,t.formData.pages.push(e(1))})}],link:function(a,e,o){var r=a.ctrl;r.formStatus&&(r.formStatus.form=r.form),r.possiblePageFlow=[];var t={nextPage:!0,label:"mwForm.pageFlow.goToNextPage"};r.possiblePageFlow.push(t),r.isSamePageFlow=function(a,e){return a.page&&e.page&&a.page.id==e.page.id||a.formSubmit&&e.formSubmit||a.nextPage&&e.nextPage},r.updatePageFlow=function(){r.possiblePageFlow.length=1,r.formData.pages.forEach(function(a){r.possiblePageFlow.push({page:{id:a.id,number:a.number},label:"mwForm.pageFlow.goToPage"})}),r.possiblePageFlow.push({formSubmit:!0,label:"mwForm.pageFlow.submitForm"}),r.formData.pages.forEach(function(a){r.possiblePageFlow.forEach(function(e){a.pageFlow?r.isSamePageFlow(e,a.pageFlow)&&(a.pageFlow=e):a.pageFlow=t,a.elements.forEach(function(a){var o=a.question;o&&o.pageFlowModifier&&o.offeredAnswers.forEach(function(a){a.pageFlow&&r.isSamePageFlow(e,a.pageFlow)&&(a.pageFlow=e)})})})})},a.$watch("ctrl.formData.pages.length",function(a,e){r.updatePageFlow()})}}}); diff --git a/dist/i18n/en/angular-surveys.json b/dist/i18n/en/angular-surveys.json index eb3d667..caa6e71 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"},"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"},"checkbox":{"name":"Checkboxes"},"grid":{"name":"Grid"},"priority":{"name":"Priority"},"division":{"name":"Division"}},"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"},"orLabel":"or ","otherLabel":"Other: ","userAnswer":"User answer","buttons":{"addOption":"Click to add option","addOther":"Add 'Other'"}},"image":{"selectImageButton":"Select image"},"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"},"checkbox":{"name":"Checkboxes"},"grid":{"name":"Grid"},"priority":{"name":"Priority"},"division":{"name":"Division"}},"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"},"orLabel":"or ","otherLabel":"Other: ","userAnswer":"User answer","buttons":{"addOption":"Click to add option","addOther":"Add 'Other'"}},"image":{"selectImageButton":"Select image"},"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/pl/angular-surveys.json b/dist/i18n/pl/angular-surveys.json index 5878ee9..73d78a4 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ń"},"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"},"checkbox":{"name":"Wielokrotny wybór"},"grid":{"name":"Siatka"},"priority":{"name":"Lista priorytetowa"},"division":{"name":"Podział"}},"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ę"},"orLabel":"lub ","otherLabel":"Inna: ","userAnswer":"Odpowiedź użytkownika","buttons":{"addOption":"Kliknij aby dodać opcję","addOther":"Dodaj \"Inne\""}},"image":{"selectImageButton":"Wybierz obraz"},"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"},"checkbox":{"name":"Wielokrotny wybór"},"grid":{"name":"Siatka"},"priority":{"name":"Lista priorytetowa"},"division":{"name":"Podział"}},"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ę"},"orLabel":"lub ","otherLabel":"Inna: ","userAnswer":"Odpowiedź użytkownika","buttons":{"addOption":"Kliknij aby dodać opcję","addOther":"Dodaj \"Inne\""}},"image":{"selectImageButton":"Wybierz obraz"},"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/gulpfile.js b/gulpfile.js index c27f90b..3a4d253 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -63,6 +63,7 @@ function buildModuleStream(dest, moduleName) { .pipe(plugins.angularFilesort()) .pipe(plugins.ngAnnotate()) .pipe(plugins.uglify()) + .pipe(plugins.stripDebug()) .pipe(plugins.concat(dest)) .pipe(gulp.dest('dist')); diff --git a/i18n/en/angular-surveys.json b/i18n/en/angular-surveys.json index 4484133..7c9cb78 100644 --- a/i18n/en/angular-surveys.json +++ b/i18n/en/angular-surveys.json @@ -18,7 +18,10 @@ "submit": "Submit", "begin": "Begin", "fold": "Fold", - "unfold": "Unfold" + "unfold": "Unfold", + "edit": "Edit", + "clone": "Clone", + "view": "View" }, "page":{ "tab":{ diff --git a/i18n/pl/angular-surveys.json b/i18n/pl/angular-surveys.json index 7306332..b9263d9 100644 --- a/i18n/pl/angular-surveys.json +++ b/i18n/pl/angular-surveys.json @@ -18,7 +18,10 @@ "submit": "Prześlij", "begin": "Rozpocznij", "fold": "Zwiń", - "unfold": "Rozwiń" + "unfold": "Rozwiń", + "edit": "Edytuj", + "clone": "Klonuj", + "view": "Wyświetl" }, "page":{ "tab":{ diff --git a/package.json b/package.json index 78e45a6..2e47316 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "gulp-rename": "^1.2.2", "gulp-sass": "^2.0.0", "gulp-sourcemaps": "^1.5.1", + "gulp-strip-debug": "^1.1.0", "gulp-uglify": "^1.5.1", "gulp-util": "^3.0.4", "jasmine-core": "^2.4.1", diff --git a/src/builder/form-page-builder.directive.js b/src/builder/form-page-builder.directive.js index 3234f46..c0f367f 100644 --- a/src/builder/form-page-builder.directive.js +++ b/src/builder/form-page-builder.directive.js @@ -65,6 +65,52 @@ angular.module('mwFormBuilder').directive('mwFormPageBuilder', function () { ctrl.formPage.elements.push(element); }; + ctrl.cloneElement = function(pageElement, setActive){ + var index = ctrl.formPage.elements.indexOf(pageElement); + var element = {}; + angular.copy(pageElement, element); + if(setActive){ + ctrl.activeElement=element; + } + resetIds(element,true); + ctrl.formPage.elements.splice(index,0, element); + + }; + + var checkedObjects = []; + function resetIds(obj, root){ + if(root){ + checkedObjects=[]; + } + if(checkedObjects.indexOf(obj)>=0){ + return; + } + checkedObjects.push(obj); + if(!obj === Object(obj)){ + return; + } + + if(Array.isArray(obj)){ + obj.forEach(resetIds); + return; + } + + for (var property in obj) { + if (obj.hasOwnProperty(property)) { + resetIds(obj[property]); + } + } + + if(obj.hasOwnProperty('id')){ + var newId = mwFormUuid.get(); + var oldId = obj.id; + console.log('setting new id:',newId, oldId, obj); + obj.id = newId; + } + + + } + ctrl.removeElement = function(pageElement){ var index = ctrl.formPage.elements.indexOf(pageElement); ctrl.formPage.elements.splice(index,1); @@ -114,8 +160,6 @@ angular.module('mwFormBuilder').directive('mwFormPageBuilder', function () { }); }; - - function createEmptyElement(type,orderNo){ return { id: mwFormUuid.get(), diff --git a/src/builder/form-page-element-builder.directive.js b/src/builder/form-page-element-builder.directive.js index 696c1ba..8900140 100644 --- a/src/builder/form-page-element-builder.directive.js +++ b/src/builder/form-page-element-builder.directive.js @@ -68,6 +68,12 @@ angular.module('mwFormBuilder').directive('mwFormPageElementBuilder', function ( pageBuilderCtrl.selectElement(ctrl.pageElement); }; + ctrl.cloneElement=function($event){ + $event.preventDefault(); + $event.stopPropagation(); + pageBuilderCtrl.cloneElement(ctrl.pageElement); + }; + ctrl.removeElement=function(){ pageBuilderCtrl.removeElement(ctrl.pageElement); }; diff --git a/src/builder/mw-form-page-element-builder.html b/src/builder/mw-form-page-element-builder.html index f725949..d8f6313 100644 --- a/src/builder/mw-form-page-element-builder.html +++ b/src/builder/mw-form-page-element-builder.html @@ -16,8 +16,18 @@
- - + + +