Skip to content

Commit

Permalink
gulp-strip-debug, clone page element button
Browse files Browse the repository at this point in the history
  • Loading branch information
mwasiluk committed Feb 8, 2016
1 parent 2d5ef74 commit 97edf4b
Show file tree
Hide file tree
Showing 10 changed files with 79 additions and 11 deletions.
6 changes: 3 additions & 3 deletions dist/form-builder.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/i18n/en/angular-surveys.json
Original file line number Diff line number Diff line change
@@ -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."}}}
{"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."}}}
2 changes: 1 addition & 1 deletion dist/i18n/pl/angular-surveys.json
Original file line number Diff line number Diff line change
@@ -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."}}}
{"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."}}}
1 change: 1 addition & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'));

Expand Down
5 changes: 4 additions & 1 deletion i18n/en/angular-surveys.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@
"submit": "Submit",
"begin": "Begin",
"fold": "Fold",
"unfold": "Unfold"
"unfold": "Unfold",
"edit": "Edit",
"clone": "Clone",
"view": "View"
},
"page":{
"tab":{
Expand Down
5 changes: 4 additions & 1 deletion i18n/pl/angular-surveys.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@
"submit": "Prześlij",
"begin": "Rozpocznij",
"fold": "Zwiń",
"unfold": "Rozwiń"
"unfold": "Rozwiń",
"edit": "Edytuj",
"clone": "Klonuj",
"view": "Wyświetl"
},
"page":{
"tab":{
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
48 changes: 46 additions & 2 deletions src/builder/form-page-builder.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -114,8 +160,6 @@ angular.module('mwFormBuilder').directive('mwFormPageBuilder', function () {
});
};



function createEmptyElement(type,orderNo){
return {
id: mwFormUuid.get(),
Expand Down
6 changes: 6 additions & 0 deletions src/builder/form-page-element-builder.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
Expand Down
14 changes: 12 additions & 2 deletions src/builder/mw-form-page-element-builder.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,18 @@
<i class="fa fa-trash"></i></button>
</div>
<div ng-switch-when="false">
<button type="button" aria-label="Edytuj element" aria-hidden="false" class="edit-button" ng-click="ctrl.editElement()" ng-if="!ctrl.readOnly"><i class="fa fa-pencil"></i></button>
<button type="button" aria-label="Wyświetl element" aria-hidden="false" class="edit-button" ng-click="ctrl.editElement()" ng-if="ctrl.readOnly"><i class="fa fa-eye"></i></button>
<button type="button" aria-label="{{'mwForm.buttons.clone' | translate}}" aria-hidden="false" class="edit-button" ng-click="ctrl.cloneElement($event)" ng-if="!ctrl.readOnly"
ng-attr-title="{{'mwForm.buttons.clone' | translate}}" popover="{{'mwForm.buttons.clone' | translate}}" popover-trigger="mouseenter" popover-placement="left">
<i class="fa fa-clone"></i>
</button>
<button type="button" aria-label="{{'mwForm.buttons.edit' | translate}}" aria-hidden="false" class="edit-button" ng-click="ctrl.editElement()" ng-if="!ctrl.readOnly"
ng-attr-title="{{'mwForm.buttons.edit' | translate}}" popover="{{'mwForm.buttons.edit' | translate}}" popover-trigger="mouseenter" popover-placement="left">
<i class="fa fa-pencil"></i>
</button>
<button type="button" aria-label="{{'mwForm.buttons.view' | translate}}" aria-hidden="false" class="edit-button" ng-click="ctrl.editElement()" ng-if="ctrl.readOnly"
ng-attr-title="{{'mwForm.buttons.view' | translate}}" popover="{{'mwForm.buttons.view' | translate}}" popover-trigger="mouseenter" popover-placement="left">
<i class="fa fa-eye"></i>
</button>
</div>
</div>
<div ng-switch="ctrl.pageElement.type">
Expand Down

0 comments on commit 97edf4b

Please sign in to comment.