diff --git a/app/assets/javascripts/admin/bulk_order_management.js.coffee b/app/assets/javascripts/admin/bulk_order_management.js.coffee index 422832f6dd..cb43ee2558 100644 --- a/app/assets/javascripts/admin/bulk_order_management.js.coffee +++ b/app/assets/javascripts/admin/bulk_order_management.js.coffee @@ -11,7 +11,6 @@ angular.module("ofn.admin").controller "AdminOrderMgmtCtrl", [ $scope.confirmDelete = true $scope.startDate = formatDate start $scope.endDate = formatDate end - $scope.pendingChanges = pendingChanges $scope.quickSearch = "" $scope.bulkActions = [ { name: "Delete Selected", callback: $scope.deleteLineItems } ] $scope.selectedBulkAction = $scope.bulkActions[0] @@ -111,6 +110,12 @@ angular.module("ofn.admin").controller "AdminOrderMgmtCtrl", [ $scope.deleteLineItem lineItem for lineItem in lineItems when lineItem.checked $scope.confirmDelete = existingState + $scope.submit = -> + if $scope.bulk_order_form.$valid + pendingChanges.submitAll() + else + alert "Some errors must be resolved be before you can update orders.\nAny fields with red borders contain errors." + $scope.allBoxesChecked = -> checkedCount = $scope.filteredLineItems.reduce (count,lineItem) -> count + (if lineItem.checked then 1 else 0 ) diff --git a/app/assets/stylesheets/admin/validation.css.scss b/app/assets/stylesheets/admin/validation.css.scss new file mode 100644 index 0000000000..c97335a6c4 --- /dev/null +++ b/app/assets/stylesheets/admin/validation.css.scss @@ -0,0 +1,7 @@ +input.ng-invalid { + border: solid 1px red; + + &.update-pending { + border: solid 1px red; + } +} diff --git a/app/views/spree/admin/orders/bulk_management.html.haml b/app/views/spree/admin/orders/bulk_management.html.haml index ca6eac718a..07205929bf 100644 --- a/app/views/spree/admin/orders/bulk_management.html.haml +++ b/app/views/spree/admin/orders/bulk_management.html.haml @@ -100,7 +100,7 @@ %div{ :class => "sixteen columns alpha", 'ng-show' => '!loading && filteredLineItems.length == 0'} %h1#no_results No orders found. %div{ 'ng-hide' => 'loading || filteredLineItems.length == 0' } - %form{ 'ng-model' => "bulk_order_form" } + %form{ name: 'bulk_order_form' } %table.index#listing_orders.bulk{ :class => "sixteen columns alpha" } %thead %tr{ ng: { controller: "ColumnsCtrl" } } @@ -146,14 +146,14 @@ %td.variant{ 'ng-show' => 'columns.variant.visible' } %a{ :href => '#', 'ng-click' => "setSelectedUnitsVariant(line_item.units_product,line_item.units_variant)" } {{ line_item.units_variant.full_name }} %td.quantity{ 'ng-show' => 'columns.quantity.visible' } - %input{ :type => 'number', :name => 'quantity', :id => 'quantity', 'ng-model' => "line_item.quantity", 'ng-change' => "updateOnQuantity(line_item)", 'obj-for-update' => "line_item", "attr-for-update" => "quantity" } + %input{ :type => 'number', :name => 'quantity', :id => 'quantity', ng: { model: "line_item.quantity", change: "updateOnQuantity(line_item)", required: "true" }, min: 1, 'obj-for-update' => "line_item", "attr-for-update" => "quantity" } %td.max{ 'ng-show' => 'columns.max.visible' } {{ line_item.max_quantity }} %td.final_weight_volume{ 'ng-show' => 'columns.final_weight_volume.visible' } - %input{ :type => 'text', :name => 'final_weight_volume', :id => 'final_weight_volume', 'ng-model' => "line_item.final_weight_volume", 'ng-readonly' => "unitValueLessThanZero(line_item)", 'ng-change' => "weightAdjustedPrice(line_item)", 'obj-for-update' => "line_item", "attr-for-update" => "final_weight_volume" } + %input{ :type => 'number', :name => 'final_weight_volume', :id => 'final_weight_volume', ng: { model: "line_item.final_weight_volume", readonly: "unitValueLessThanZero(line_item)", change: "weightAdjustedPrice(line_item)", required: "true" }, min: 0.001, 'obj-for-update' => "line_item", "attr-for-update" => "final_weight_volume" } %td.price{ 'ng-show' => 'columns.price.visible' } %input{ :type => 'text', :name => 'price', :id => 'price', :value => '{{ line_item.price * line_item.quantity | currency }}', 'ng-readonly' => "true", 'obj-for-update' => "line_item", "attr-for-update" => "price" } %td.actions %a{ :class => "edit-order icon-edit no-text", 'ofn-confirm-link-path' => "/admin/orders/{{line_item.order.number}}/edit" } %td.actions %a{ 'ng-click' => "deleteLineItem(line_item)", :class => "delete-line-item icon-trash no-text" } - %input{ :type => "button", 'value' => 'Update', 'ng-click' => 'pendingChanges.submitAll()' } + %input{ :type => "button", 'value' => 'Update', 'ng-click' => 'submit()' }