From 126f11683d8d4b80ec8cd85a02ccf335df655a02 Mon Sep 17 00:00:00 2001 From: Rob H Date: Sat, 22 Jun 2013 13:13:24 +0530 Subject: [PATCH] BPUR: Add datetimepicker to Available On --- .../javascripts/admin/bulk_product_update.js | 20 +++++++++++++++++++ .../spree/admin/products/bulk_edit.html.haml | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/admin/bulk_product_update.js b/app/assets/javascripts/admin/bulk_product_update.js index 712fce1bad..2e8dbb8f1d 100644 --- a/app/assets/javascripts/admin/bulk_product_update.js +++ b/app/assets/javascripts/admin/bulk_product_update.js @@ -119,6 +119,26 @@ productsApp.directive('ngToggleColumnList', function($compile){ } }); +productsApp.directive('datetimepicker', function ($parse) { + return function (scope, element, attrs) { + // using $parse instead of scope[attrs.datetimepicker] for cases + // where attrs.datetimepicker is 'foo.bar.lol' + $(function(){ + element.datetimepicker({ + dateFormat: 'yy-mm-dd', + timeFormat: 'HH:mm:ss', + stepMinute: 15, + onSelect:function (dateText, inst) { + scope.$apply(function(scope){ + parsed = $parse(attrs.datetimepicker); + parsed.assign(scope, dateText); + }); + } + }); + }); + } +}); + productsApp.controller('AdminBulkProductsCtrl', function($scope, $timeout, $http, dataFetcher) { $scope.updateStatusMessage = { text: "", diff --git a/app/views/spree/admin/products/bulk_edit.html.haml b/app/views/spree/admin/products/bulk_edit.html.haml index 75efe38463..82b1a8d96b 100644 --- a/app/views/spree/admin/products/bulk_edit.html.haml +++ b/app/views/spree/admin/products/bulk_edit.html.haml @@ -46,7 +46,7 @@ %span{ 'ng-bind' => 'product.on_hand', :name => 'on_hand', 'ng-show' => 'hasVariants(product)' } %input.field{ 'ng-model' => 'product.on_hand', :name => 'on_hand', 'ng-track-product' => 'on_hand', 'ng-show' => '!hasVariants(product)', :type => 'number' } %td{ 'ng-show' => 'columns.available_on.visible' } - %input{ 'ng-model' => 'product.available_on', :name => 'available_on', 'ng-track-product' => 'available_on', :type => 'text' } + %input{ 'ng-model' => 'product.available_on', :name => 'available_on', 'ng-track-product' => 'available_on', 'datetimepicker' => 'product.available_on', type: "text" } %td.actions %a{ 'ng-click' => 'editWarn(product)', :class => "edit-product icon-edit no-text" } %a{ 'ng-click' => 'cloneProduct(product)', :class => "clone-product icon-copy no-text" }