Commit 2bbb09a435d6545a436914ad16e986869e3daf3c
1 parent
a7852ace
Exists in
master
Criação da possibilidade de alterar a linha do componente no form builder
Showing
5 changed files
with
55 additions
and
4 deletions
Show diff stats
cit-esi-api/src/main/java/br/com/centralit/esi/api/resource/model/FormComponent.java
| ... | ... | @@ -27,7 +27,7 @@ import com.fasterxml.jackson.annotation.JsonView; |
| 27 | 27 | |
| 28 | 28 | @Entity |
| 29 | 29 | @Table(name="RES_FormComponent") |
| 30 | -@JsonIgnoreProperties({ "$type", "rowIndex" }) | |
| 30 | +@JsonIgnoreProperties({ "$type", "rowIndex", "rowIndexInput" }) | |
| 31 | 31 | public class FormComponent extends PersistentObject { |
| 32 | 32 | |
| 33 | 33 | /** | ... | ... |
cit-esi-web/src/main/java/br/com/centralit/listener/StartupListenerEsi.java
| ... | ... | @@ -1635,7 +1635,18 @@ public class StartupListenerEsi extends UtilStartup implements ApplicationListen |
| 1635 | 1635 | formWidget.getProperties().add(new FormWidgetProperty(formWidget, this.findProperty("ng-obrigatorio", properties))); |
| 1636 | 1636 | formWidget.getProperties().add(new FormWidgetProperty(formWidget, this.findProperty("ng-disabled", properties))); |
| 1637 | 1637 | |
| 1638 | - formWidget.setTemplateCode("<auto-complete ng-id=\"component_{{component.rowIndex}}_{{component.index}}\" ng-label=\"{{component['ng-label']}}\" ng-model=\"model\" ng-item=\"item\" />"); | |
| 1638 | + String html = "<div class=\"form-group\" >\n"+ | |
| 1639 | + " <label ><translate>{{component['ng-label']}}</translate>\n"+ | |
| 1640 | + " </label>\n"+ | |
| 1641 | + " <div id=\"{{id}}\" class=\"input-group\">\n"+ | |
| 1642 | + " <input class=\"form-control typeahead-wide\" type=\"text\"/>\n"+ | |
| 1643 | + " <span class=\"input-group-addon\">\n"+ | |
| 1644 | + " <i class=\"fa fa-search bigger-110\"></i>\n"+ | |
| 1645 | + " </span>\n"+ | |
| 1646 | + " </div>\n"+ | |
| 1647 | + "</div>"; | |
| 1648 | + | |
| 1649 | + formWidget.setTemplateCode(html); | |
| 1639 | 1650 | formWidget.setHtmlCode("<auto-complete ng-id=\"${id}\" form=\"${form}\" " + this.buildHTMLProperties(formWidget) + " />"); |
| 1640 | 1651 | formWidgetService.save(formWidget); |
| 1641 | 1652 | } |
| ... | ... | @@ -1658,7 +1669,18 @@ public class StartupListenerEsi extends UtilStartup implements ApplicationListen |
| 1658 | 1669 | formWidget.getProperties().add(new FormWidgetProperty(formWidget, this.findProperty("ng-obrigatorio", properties))); |
| 1659 | 1670 | formWidget.getProperties().add(new FormWidgetProperty(formWidget, this.findProperty("ng-disabled", properties))); |
| 1660 | 1671 | |
| 1661 | - formWidget.setTemplateCode("<auto-complete ng-id=\"component_{{component.rowIndex}}_{{component.index}}\" ng-label=\"{{component['ng-label']}}\" ng-model=\"model\" />"); | |
| 1672 | + String html = "<div class=\"form-group\" >\n"+ | |
| 1673 | + " <label ><translate>{{component['ng-label']}}</translate>\n"+ | |
| 1674 | + " </label>\n"+ | |
| 1675 | + " <div id=\"{{id}}\" class=\"input-group\">\n"+ | |
| 1676 | + " <input class=\"form-control typeahead-wide\" type=\"text\"/>\n"+ | |
| 1677 | + " <span class=\"input-group-addon\">\n"+ | |
| 1678 | + " <i class=\"fa fa-search bigger-110\"></i>\n"+ | |
| 1679 | + " </span>\n"+ | |
| 1680 | + " </div>\n"+ | |
| 1681 | + "</div>"; | |
| 1682 | + | |
| 1683 | + formWidget.setTemplateCode(html); | |
| 1662 | 1684 | formWidget.setHtmlCode("<esi-data-search ng-if=\"${ng-target}\" ng-id=\"${id}\" form=\"${form}\" " + this.buildHTMLProperties(formWidget) + " />"); |
| 1663 | 1685 | formWidgetService.save(formWidget); |
| 1664 | 1686 | } | ... | ... |
cit-esi-web/src/main/webapp/assets/js/angular/custom/directive/FormBuilderDirective.js
| ... | ... | @@ -210,7 +210,7 @@ citApp.directive("formBuilder", ['ImageRepository', '$translate', '$filter', '$t |
| 210 | 210 | if (!row.htmlOnly) { |
| 211 | 211 | var width = !$scope.isMaxWidth(widget) ? $scope.getWidth(row) : 12; |
| 212 | 212 | if (width > 0) { |
| 213 | - var component = {widget: widget, rowIndex: row.index, index: row.components.length, width: width}; | |
| 213 | + var component = {widget: widget, rowIndex: row.index, rowIndexInput: row.index+1, index: row.components.length, width: width}; | |
| 214 | 214 | row.components.push(component); |
| 215 | 215 | $scope.addProperties(component); |
| 216 | 216 | return component; |
| ... | ... | @@ -385,6 +385,20 @@ citApp.directive("formBuilder", ['ImageRepository', '$translate', '$filter', '$t |
| 385 | 385 | } |
| 386 | 386 | } |
| 387 | 387 | |
| 388 | + $scope.changeComponentRow = function(component) { | |
| 389 | + if (component.rowIndexInput != component.rowIndex + 1) { | |
| 390 | + var row = $scope.formContainer.rows[component.rowIndex]; | |
| 391 | + row.components.splice(component.index, 1); | |
| 392 | + $scope.reorderComponents(row); | |
| 393 | + | |
| 394 | + component.rowIndex = component.rowIndexInput - 1; | |
| 395 | + row = $scope.formContainer.rows[component.rowIndex]; | |
| 396 | + component.index = row.components.length - 1; | |
| 397 | + row.components.push(component); | |
| 398 | + $scope.reorderComponents(row); | |
| 399 | + } | |
| 400 | + } | |
| 401 | + | |
| 388 | 402 | $scope.allowRowUp = function(row) { |
| 389 | 403 | if (row) { |
| 390 | 404 | return row.index > 0; |
| ... | ... | @@ -436,6 +450,7 @@ citApp.directive("formBuilder", ['ImageRepository', '$translate', '$filter', '$t |
| 436 | 450 | var index = 0; |
| 437 | 451 | angular.forEach(row.components, function(component){ |
| 438 | 452 | component.rowIndex = row.index; |
| 453 | + component.rowIndexInput = row.index+1; | |
| 439 | 454 | component.index = index; |
| 440 | 455 | index ++; |
| 441 | 456 | }); | ... | ... |
cit-esi-web/src/main/webapp/assets/js/angular/custom/directive/html/formBuilder.html
| ... | ... | @@ -161,6 +161,19 @@ |
| 161 | 161 | </div> |
| 162 | 162 | </div> |
| 163 | 163 | </div> |
| 164 | + <div class="form-group" > | |
| 165 | + <label for=currentComponent.rowIndexInput> <translate> <span class="">ESI.LINHA</span></translate> | |
| 166 | + <i class="fa fa-info-circle" tooltip-placement="top" | |
| 167 | + tooltip="Linha do componente" | |
| 168 | + tooltip-append-to-body="true"></i> | |
| 169 | + </label> | |
| 170 | + <div class="inner-addon left-addon"> | |
| 171 | + <i class="fa fa-align-justify bold text-normal"></i> <input | |
| 172 | + ng-model="currentComponent.rowIndexInput" type="number" | |
| 173 | + class="form-control property--width input-sm ng-valid ng-valid-min ng-valid-max ng-dirty ng-touched" | |
| 174 | + id="currentComponent.rowIndexInput" min="1" max="{{formContainer.rows.length}}" ng-change="changeComponentRow(currentComponent)"> | |
| 175 | + </div> | |
| 176 | + </div> | |
| 164 | 177 | <div style="height:395px;overflow-x: hidden;overflow-y: auto; padding: 0px 0px 0px 0px"> |
| 165 | 178 | <div class='row no-padding' ng-if="currentComponent.widget.type.name == 'HTML'"> |
| 166 | 179 | <label-ui-ace ng-label="ESI.HTML" ng-theme="eclipse" ng-mode="html" ng-model="currentComponent.htmlCode" | ... | ... |
cit-esi-web/src/main/webapp/assets/js/angular/custom/utils/FormContainerHelper.js
| ... | ... | @@ -89,6 +89,7 @@ FormContainerHelper.setProperties = function(formContainer) { |
| 89 | 89 | var componentIndex = 0; |
| 90 | 90 | angular.forEach(row.components, function(component){ |
| 91 | 91 | component.rowIndex = row.index; |
| 92 | + component.rowIndexInput = row.index + 1; | |
| 92 | 93 | component.index = componentIndex; |
| 93 | 94 | componentIndex ++; |
| 94 | 95 | ... | ... |