Auto-merge from CI [skip ci]

This commit is contained in:
Continuous Integration
2016-06-30 01:30:53 +10:00
279 changed files with 4510 additions and 1745 deletions

View File

@@ -1,6 +1,9 @@
engines:
rubocop:
enabled: true
exclude_fingerprints:
- ac41db8d4ec4cbf508c353d9b65a024f
- 8e3b6322aef5be9f38700b3fd0cd347e
scss-lint:
enabled: true
ratings:

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.2 KiB

After

Width:  |  Height:  |  Size: 9.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 9.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.9 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 317 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

After

Width:  |  Height:  |  Size: 619 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 86 KiB

After

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 71 KiB

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 313 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.2 KiB

After

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 124 KiB

After

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1003 KiB

After

Width:  |  Height:  |  Size: 138 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 108 KiB

After

Width:  |  Height:  |  Size: 105 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 662 KiB

After

Width:  |  Height:  |  Size: 570 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 300 KiB

After

Width:  |  Height:  |  Size: 283 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 215 KiB

After

Width:  |  Height:  |  Size: 206 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 256 KiB

After

Width:  |  Height:  |  Size: 244 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 197 KiB

After

Width:  |  Height:  |  Size: 195 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 125 KiB

After

Width:  |  Height:  |  Size: 92 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 784 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 840 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.9 KiB

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.0 KiB

After

Width:  |  Height:  |  Size: 8.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 535 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.2 KiB

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 971 B

After

Width:  |  Height:  |  Size: 957 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.6 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.5 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.0 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.2 KiB

After

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

After

Width:  |  Height:  |  Size: 39 KiB

BIN
app/assets/images/select2.png Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 881 B

BIN
app/assets/images/select2x2.png Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 928 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 112 KiB

After

Width:  |  Height:  |  Size: 54 KiB

View File

@@ -1,4 +1,4 @@
angular.module("ofn.admin").controller "AdminProductEditCtrl", ($scope, $timeout, $http, BulkProducts, DisplayProperties, dataFetcher, DirtyProducts, VariantUnitManager, StatusMessage, producers, Taxons, SpreeApiAuth, Columns, tax_categories) ->
angular.module("ofn.admin").controller "AdminProductEditCtrl", ($scope, $timeout, $http, $window, BulkProducts, DisplayProperties, dataFetcher, DirtyProducts, VariantUnitManager, StatusMessage, producers, Taxons, SpreeApiAuth, Columns, tax_categories) ->
$scope.loading = true
$scope.StatusMessage = StatusMessage
@@ -206,6 +206,8 @@ angular.module("ofn.admin").controller "AdminProductEditCtrl", ($scope, $timeout
else
$scope.displayFailure t("products_update_error_data") + status
$scope.cancel = (destination) ->
$window.location = destination
$scope.packProduct = (product) ->
if product.variant_unit_with_scale
@@ -247,6 +249,7 @@ angular.module("ofn.admin").controller "AdminProductEditCtrl", ($scope, $timeout
$scope.displaySuccess = ->
StatusMessage.display 'success',t("products_changes_saved")
$scope.bulk_product_form.$setPristine()
$scope.displayFailure = (failMessage) ->

View File

@@ -1,6 +1,5 @@
angular.module("admin.customers").controller "customersCtrl", ($scope, $q, Customers, TagRuleResource, CurrentShop, RequestMonitor, Columns, pendingChanges, shops) ->
angular.module("admin.customers").controller "customersCtrl", ($scope, $q, $filter, Customers, TagRuleResource, CurrentShop, RequestMonitor, Columns, pendingChanges, shops) ->
$scope.shops = shops
$scope.CurrentShop = CurrentShop
$scope.RequestMonitor = RequestMonitor
$scope.submitAll = pendingChanges.submitAll
$scope.add = Customers.add
@@ -8,15 +7,37 @@ angular.module("admin.customers").controller "customersCtrl", ($scope, $q, Custo
$scope.customerLimit = 20
$scope.columns = Columns.columns
$scope.$watch "CurrentShop.shop", ->
if $scope.CurrentShop.shop.id?
Customers.index({enterprise_id: $scope.CurrentShop.shop.id}).then (data) ->
$scope.confirmRefresh = (event) ->
event.preventDefault() unless pendingChanges.unsavedCount() == 0 || confirm(t("unsaved_changes_warning"))
$scope.$watch "shop_id", ->
if $scope.shop_id?
CurrentShop.shop = $filter('filter')($scope.shops, {id: $scope.shop_id})[0]
Customers.index({enterprise_id: $scope.shop_id}).then (data) ->
pendingChanges.removeAll()
$scope.customers_form.$setPristine()
$scope.customers = data
$scope.shop_id = shops[0].id if shops.length == 1
$scope.checkForDuplicateCodes = ->
delete this.customer.code unless this.customer.code
this.duplicate = $scope.isDuplicateCode(this.customer.code)
$scope.isDuplicateCode = (code) ->
return false unless code
customers = $scope.findByCode(code)
customers.length > 1
$scope.findByCode = (code) ->
if $scope.customers
$scope.customers.filter (customer) ->
customer.code == code
$scope.findTags = (query) ->
defer = $q.defer()
params =
enterprise_id: $scope.CurrentShop.shop.id
enterprise_id: $scope.shop_id
TagRuleResource.mapByTag params, (data) =>
filtered = data.filter (tag) ->
tag.text.toLowerCase().indexOf(query.toLowerCase()) != -1

View File

@@ -1,20 +1,21 @@
angular.module("admin.customers").directive 'newCustomerDialog', ($compile, $injector, $templateCache, $window, CurrentShop, Customers) ->
angular.module("admin.customers").directive 'newCustomerDialog', ($compile, $injector, $templateCache, DialogDefaults, CurrentShop, Customers) ->
restrict: 'A'
scope: true
link: (scope, element, attr) ->
scope.CurrentShop = CurrentShop
scope.submitted = null
scope.submitted = false
scope.email = ""
scope.errors = []
scope.addCustomer = (valid) ->
scope.submitted = scope.email
scope.addCustomer = ->
scope.new_customer_form.$setPristine()
scope.submitted = true
scope.errors = []
if valid
if scope.new_customer_form.$valid
Customers.add(scope.email).$promise.then (data) ->
if data.id
scope.email = ""
scope.submitted = null
scope.submitted = false
template.dialog('close')
, (response) ->
if response.data.errors
@@ -27,16 +28,7 @@ angular.module("admin.customers").directive 'newCustomerDialog', ($compile, $inj
template = $compile($templateCache.get('admin/new_customer_dialog.html'))(scope)
# Set Dialog options
template.dialog
show: { effect: "fade", duration: 400 }
hide: { effect: "fade", duration: 300 }
autoOpen: false
resizable: false
width: $window.innerWidth * 0.4;
modal: true
open: (event, ui) ->
$('.ui-widget-overlay').bind 'click', ->
$(this).siblings('.ui-dialog').find('.ui-dialog-content').dialog('close')
template.dialog(DialogDefaults)
# Link opening of dialog to click event on element
element.bind 'click', (e) ->

View File

@@ -1,4 +1,4 @@
angular.module("admin.customers").factory "Customers", ($q, RequestMonitor, CustomerResource, CurrentShop) ->
angular.module("admin.customers").factory "Customers", ($q, InfoDialog, RequestMonitor, CustomerResource, CurrentShop) ->
new class Customers
customers: []
@@ -14,6 +14,12 @@ angular.module("admin.customers").factory "Customers", ($q, RequestMonitor, Cust
CustomerResource.destroy params, =>
i = @customers.indexOf customer
@customers.splice i, 1 unless i < 0
, (response) =>
errors = response.data.errors
if errors?
InfoDialog.open 'error', errors[0]
else
InfoDialog.open 'error', "Could not delete customer: #{customer.email}"
index: (params) ->
request = CustomerResource.index(params, (data) => @customers = data)

View File

@@ -4,12 +4,12 @@ angular.module("admin.enterprise_groups")
$scope.select = SideMenu.select
$scope.menu.setItems [
{ name: 'Primary Details', icon_class: "icon-user" }
{ name: (t('users')), icon_class: "icon-user" }
{ name: (t('about')), icon_class: "icon-pencil" }
{ name: (t('images')), icon_class: "icon-picture" }
{ name: (t('contact')), icon_class: "icon-phone" }
{ name: (t('web')), icon_class: "icon-globe" }
{ name: 'primary_details', label: t('primary_details'), icon_class: "icon-user" }
{ name: 'users', label: t('users'), icon_class: "icon-user" }
{ name: 'about', label: t('about'), icon_class: "icon-pencil" }
{ name: 'images', label: t('images'), icon_class: "icon-picture" }
{ name: 'contact', label: t('admin_entreprise_groups_contact'), icon_class: "icon-phone" }
{ name: 'web', label: t('admin_entreprise_groups_web'), icon_class: "icon-globe" }
]
$scope.select(0)

View File

@@ -1,5 +1,5 @@
angular.module("admin.enterprises")
.controller "enterpriseCtrl", ($scope, NavigationCheck, enterprise, EnterprisePaymentMethods, EnterpriseShippingMethods, SideMenu) ->
.controller "enterpriseCtrl", ($scope, $window, NavigationCheck, enterprise, EnterprisePaymentMethods, EnterpriseShippingMethods, SideMenu, StatusMessage) ->
$scope.Enterprise = enterprise
$scope.PaymentMethods = EnterprisePaymentMethods.paymentMethods
$scope.ShippingMethods = EnterpriseShippingMethods.shippingMethods
@@ -8,6 +8,23 @@ angular.module("admin.enterprises")
$scope.menu = SideMenu
$scope.newManager = { id: '', email: (t('add_manager')) }
$scope.StatusMessage = StatusMessage
$scope.$watch 'enterprise_form.$dirty', (newValue) ->
StatusMessage.display 'notice', 'You have unsaved changes' if newValue
$scope.setFormDirty = ->
$scope.$apply ->
$scope.enterprise_form.$setDirty()
$scope.cancel = (destination) ->
$window.location = destination
$scope.submit = ->
$scope.navClear()
enterprise_form.submit()
# Provide a callback for generating warning messages displayed before leaving the page. This is passed in
# from a directive "nav-check" in the page - if we pass it here it will be called in the test suite,
# and on all new uses of this contoller, and we might not want that .

View File

@@ -1,49 +0,0 @@
angular.module("admin.enterprises").controller "EnterpriseIndexRowCtrl", ($scope) ->
$scope.status = ->
if $scope.enterprise.issues.length > 0
"issue"
else if $scope.enterprise.warnings.length > 0
"warning"
else
"ok"
$scope.producerText = ->
switch $scope.enterprise.is_primary_producer
when true
"Producer"
else
"Non-Producer"
$scope.packageText = ->
switch $scope.enterprise.is_primary_producer
when true
switch $scope.enterprise.sells
when "none"
"Profile"
when "own"
"Shop"
when "any"
"Hub"
else
"Choose"
else
switch $scope.enterprise.sells
when "none"
"Profile"
when "any"
"Hub"
else
"Choose"
$scope.updateRowText = ->
$scope.producer = $scope.producerText()
$scope.package = $scope.packageText()
$scope.producerError = ($scope.producer == "Choose")
$scope.packageError = ($scope.package == "Choose")
$scope.updateRowText()
$scope.$on "enterprise:updated", ->
$scope.updateRowText()

View File

@@ -3,6 +3,54 @@ angular.module("admin.enterprises").controller 'enterprisesCtrl', ($scope, $q, E
requests.push ($scope.allEnterprises = Enterprises.index(ams_prefix: "index")).$promise
$q.all(requests).then ->
$scope.updateStaticFieldsFor(enterprise) for enterprise in $scope.allEnterprises
$scope.loaded = true
$scope.columns = Columns.columns
$scope.updateStaticFieldsFor = (enterprise) ->
enterprise.producer = $scope.producerTextFor(enterprise)
enterprise.package = $scope.packageTextFor(enterprise)
enterprise.producerError = (enterprise.producer == "Choose")
enterprise.packageError = (enterprise.package == "Choose")
enterprise.status = $scope.statusFor(enterprise)
$scope.$on "enterprise:updated", (event, enterprise) ->
$scope.updateStaticFieldsFor(enterprise)
$scope.statusFor = (enterprise) ->
if enterprise.issues.length > 0
"issue"
else if enterprise.warnings.length > 0
"warning"
else
"ok"
$scope.producerTextFor = (enterprise) ->
switch enterprise.is_primary_producer
when true
"Producer"
else
"Non-Producer"
$scope.packageTextFor = (enterprise) ->
switch enterprise.is_primary_producer
when true
switch enterprise.sells
when "none"
"Profile"
when "own"
"Shop"
when "any"
"Hub"
else
"Choose"
else
switch enterprise.sells
when "none"
"Profile"
when "any"
"Hub"
else
"Choose"

View File

@@ -9,7 +9,7 @@ angular.module("admin.enterprises").controller 'indexPanelCtrl', ($scope, Enterp
unless $scope.saved()
$scope.saving = true
Enterprises.save($scope.enterprise).then (data) ->
$scope.$emit("enterprise:updated")
$scope.$emit("enterprise:updated", $scope.enterprise)
$scope.saving = false
, (response) ->
$scope.saving = false

View File

@@ -5,21 +5,21 @@ angular.module("admin.enterprises")
$scope.select = SideMenu.select
$scope.menu.setItems [
{ name: t('primary_details'), icon_class: "icon-home" }
{ name: t('users'), icon_class: "icon-user" }
{ name: t('address'), icon_class: "icon-map-marker" }
{ name: t('contact'), icon_class: "icon-phone" }
{ name: t('social'), icon_class: "icon-twitter" }
{ name: t('about'), icon_class: "icon-pencil" }
{ name: t('business_details'), icon_class: "icon-briefcase" }
{ name: t('images'), icon_class: "icon-picture" }
{ name: t('properties'), icon_class: "icon-tags", show: "showProperties()" }
{ name: t('shipping_methods'), icon_class: "icon-truck", show: "showShippingMethods()" }
{ name: t('payment_methods'), icon_class: "icon-money", show: "showPaymentMethods()" }
{ name: t('enterprise_fees'), icon_class: "icon-tasks", show: "showEnterpriseFees()" }
{ name: t('inventory_settings'), icon_class: "icon-list-ol", show: "enterpriseIsShop()" }
{ name: t('tag_rules'), icon_class: "icon-random", show: "enterpriseIsShop()" }
{ name: t('shop_preferences'), icon_class: "icon-shopping-cart", show: "enterpriseIsShop()" }
{ name: 'primary_details', label: t('primary_details'), icon_class: "icon-home" }
{ name: 'users', label: t('users'), icon_class: "icon-user" }
{ name: 'address', label: t('address'), icon_class: "icon-map-marker" }
{ name: 'contact', label: t('contact'), icon_class: "icon-phone" }
{ name: 'social', label: t('social'), icon_class: "icon-twitter" }
{ name: 'about', label: t('about'), icon_class: "icon-pencil" }
{ name: 'business_details', label: t('business_details'), icon_class: "icon-briefcase" }
{ name: 'images', label: t('images'), icon_class: "icon-picture" }
{ name: 'properties', label: t('properties'), icon_class: "icon-tags", show: "showProperties()" }
{ name: 'shipping_methods', label: t('shipping_methods'), icon_class: "icon-truck", show: "showShippingMethods()" }
{ name: 'payment_methods', label: t('payment_methods'), icon_class: "icon-money", show: "showPaymentMethods()" }
{ name: 'enterprise_fees', label: t('enterprise_fees'), icon_class: "icon-tasks", show: "showEnterpriseFees()" }
{ name: 'inventory_settings', label: t('inventory_settings'), icon_class: "icon-list-ol", show: "enterpriseIsShop()" }
{ name: 'tag_rules', label: t('tag_rules'), icon_class: "icon-random", show: "enterpriseIsShop()" }
{ name: 'shop_preferences', label: t('shop_preferences'), icon_class: "icon-shopping-cart", show: "enterpriseIsShop()" }
]
$scope.select(0)

View File

@@ -1,4 +1,7 @@
angular.module("admin.enterprises").factory 'EnterpriseResource', ($resource) ->
ignoredAttrs = ->
["$$hashKey", "producer", "package", "producerError", "packageError", "status"]
$resource('/admin/enterprises/:id/:action.json', {}, {
'index':
method: 'GET'

View File

@@ -33,8 +33,11 @@ angular.module("admin.enterprises").factory 'Enterprises', ($q, EnterpriseResour
diff: (enterprise) ->
changed = []
for attr, value of enterprise when not angular.equals(value, @pristineByID[enterprise.id][attr])
changed.push attr unless attr is "$$hashKey"
changed.push attr unless attr in @ignoredAttrs()
changed
ignoredAttrs: ->
["$$hashKey", "producer", "package", "producerError", "packageError", "status"]
resetAttribute: (enterprise, attribute) ->
enterprise[attribute] = @pristineByID[enterprise.id][attribute]

View File

@@ -15,7 +15,7 @@ angular.module("admin.indexUtils").directive "objForUpdate", (switchClass, pendi
object: scope.object()
type: scope.type
attr: scope.attr
value: value
value: if value? then value else ""
scope: scope
scope.pending()
pendingChanges.add(scope.object().id, scope.attr, change)

View File

@@ -7,6 +7,7 @@ angular.module("admin.indexUtils").directive "ofnSelect2", ($sanitize, $timeout,
text: "@?"
blank: "=?"
filter: "=?"
onSelecting: "=?"
link: (scope, element, attrs, ngModel) ->
$timeout ->
scope.text ||= 'name'
@@ -24,6 +25,8 @@ angular.module("admin.indexUtils").directive "ofnSelect2", ($sanitize, $timeout,
formatResult: (item) ->
item[scope.text]
element.on "select2-opening", scope.onSelecting || angular.noop
attrs.$observe 'disabled', (value) ->
element.select2('enable', !value)

View File

@@ -0,0 +1,21 @@
angular.module("admin.indexUtils").directive "panelCtrl", (Panels) ->
restrict: "C"
scope:
object: "="
selected: "@?"
controller: ($scope, $element) ->
this.toggle = (name) ->
Panels.toggle($scope.object, name)
this.select = (selection) ->
$scope.$broadcast("selection:changed", selection)
$element.toggleClass("expanded", selection?)
this.registerSelectionListener = (callback) ->
$scope.$on "selection:changed", (event, selection) ->
callback(selection)
this
link: (scope, element, attrs, ctrl) ->
Panels.register(ctrl, scope.object, scope.selected)

View File

@@ -1,37 +1,24 @@
angular.module("admin.indexUtils").directive "panelRow", (Panels, Columns) ->
restrict: "C"
require: "^^panelCtrl"
templateUrl: "admin/panel.html"
scope:
object: "="
panels: "="
link: (scope, element, attrs) ->
scope.template = ""
selected = null
scope.columnCount = Columns.visibleCount
colspan: "=?"
locals: '@?'
link: (scope, element, attrs, ctrl) ->
scope.template = null
scope.columnCount = (scope.colspan || Columns.visibleCount)
if scope.locals
scope[local] = scope.$parent.$eval(local.trim()) for local in scope.locals.split(',')
scope.$on "columnCount:changed", (event, count) ->
scope.columnCount = count
setTemplate = ->
if selected?
scope.template = 'admin/panels/' + scope.panels[selected] + '.html'
ctrl.registerSelectionListener (selection) ->
if selection?
scope.template = "admin/panels/#{scope.panels[selection]}.html"
else
scope.template = ""
scope.getSelected = ->
selected
scope.setSelected = (name) ->
scope.$apply ->
selected = name
setTemplate()
scope.open = (name) ->
element.show 0, ->
scope.setSelected name
scope.close = ->
element.hide 0, ->
scope.setSelected null
Panels.register(scope.object.id, scope)
scope.template = null

View File

@@ -2,11 +2,13 @@ angular.module("admin.indexUtils").directive "panelToggle", ->
restrict: "C"
transclude: true
template: '<div ng-transclude></div><i class=\'icon-chevron\'></i>'
require: "^panelToggleRow"
require: "^^panelCtrl"
scope:
name: "@"
link: (scope, element, attrs, ctrl) ->
scope.selected = ctrl.register(scope.name, element)
element.on "click", ->
scope.selected = ctrl.select(scope.name)
scope.$apply ->
ctrl.toggle(scope.name)
ctrl.registerSelectionListener (selection) ->
element.toggleClass('selected', selection == scope.name)

View File

@@ -1,29 +0,0 @@
angular.module("admin.indexUtils").directive "panelToggleRow", (Panels) ->
restrict: "C"
scope:
object: "="
selected: "@?"
controller: ($scope) ->
panelToggles = {}
this.register = (name, element) ->
panelToggles[name] = element
panelToggles[name].addClass("selected") if $scope.selected == name
$scope.selected == name
this.select = (name) ->
panelToggle.removeClass("selected") for panelName, panelToggle of panelToggles
switch $scope.selected = Panels.toggle($scope.object.id, name)
when null
panelToggles[name].parent(".panel-toggle-row").removeClass("expanded")
else
panelToggles[$scope.selected].addClass("selected")
panelToggles[$scope.selected].parent(".panel-toggle-row").addClass("expanded")
$scope.selected == name
this
#
# link: (scope, element, attrs) ->
# Panels.registerInitialSelection(scope.object.id, scope.selected)

View File

@@ -1,4 +1,4 @@
angular.module("admin.indexUtils").factory 'Columns', ($rootScope, $http, columns) ->
angular.module("admin.indexUtils").factory 'Columns', ($rootScope, $http, $injector) ->
new class Columns
savedColumns: {}
columns: {}
@@ -6,11 +6,17 @@ angular.module("admin.indexUtils").factory 'Columns', ($rootScope, $http, column
constructor: ->
@columns = {}
for column in columns
for column in @injectColumns()
@columns[column.column_name] = column
@savedColumns[column.column_name] = angular.copy(column)
@calculateVisibleCount()
injectColumns: ->
if $injector.has('columns')
$injector.get('columns')
else
[]
toggleColumn: (column) =>
column.visible = !column.visible
@calculateVisibleCount()

View File

@@ -1,19 +1,22 @@
angular.module("admin.indexUtils").factory 'Panels', ->
new class Panels
panels: {}
panels: []
register: (id, scope) ->
if id? && scope?
@panels[id] = scope
register: (ctrl, object, selected=null) ->
if ctrl? && object?
@panels.push { ctrl: ctrl, object: object, selected: selected }
ctrl.select(selected) if selected?
toggle: (id, name) ->
scope = @panels[id]
selected = scope.getSelected()
switch selected
when name
scope.close()
when null
scope.open(name)
else
scope.setSelected(name)
scope.getSelected()
toggle: (object, name, state=null) ->
panel = @findPanelByObject(object)
if panel.selected == name
@select(panel, null) unless state == "open"
else
@select(panel, name) unless state == "closed"
select: (panel, name) ->
panel.selected = name
panel.ctrl.select(name)
findPanelByObject: (object) ->
(panel for panel in @panels when panel.object == object)[0]

View File

@@ -10,6 +10,8 @@ angular.module("admin.indexUtils").factory "pendingChanges", ($q, resources, Sta
removeAll: =>
@pendingChanges = {}
StatusMessage.clear()
remove: (id, attr) =>
if @pendingChanges.hasOwnProperty("#{id}")
@@ -40,5 +42,8 @@ angular.module("admin.indexUtils").factory "pendingChanges", ($q, resources, Sta
@errors.push error
change.scope.error()
unsavedCount: ->
Object.keys(@pendingChanges).length
changeCount: (objectChanges) ->
Object.keys(objectChanges).length

View File

@@ -1,5 +1,5 @@
angular.module('admin.orderCycles')
.controller 'AdminCreateOrderCycleCtrl', ($scope, $filter, OrderCycle, Enterprise, EnterpriseFee, ocInstance, StatusMessage) ->
.controller 'AdminCreateOrderCycleCtrl', ($scope, $filter, $window, OrderCycle, Enterprise, EnterpriseFee, ocInstance, StatusMessage) ->
$scope.enterprises = Enterprise.index(coordinator_id: ocInstance.coordinator_id)
$scope.supplier_enterprises = Enterprise.producer_enterprises
$scope.distributor_enterprises = Enterprise.hub_enterprises
@@ -11,6 +11,9 @@ angular.module('admin.orderCycles')
$scope.StatusMessage = StatusMessage
$scope.$watch 'order_cycle_form.$dirty', (newValue) ->
StatusMessage.display 'notice', 'You have unsaved changes' if newValue
$scope.loaded = ->
Enterprise.loaded && EnterpriseFee.loaded && OrderCycle.loaded
@@ -41,10 +44,6 @@ angular.module('admin.orderCycles')
$scope.enterprisesWithFees = ->
$scope.enterprises[id] for id in OrderCycle.participatingEnterpriseIds() when $scope.enterpriseFeesForEnterprise(id).length > 0
$scope.toggleProducts = ($event, exchange) ->
$event.preventDefault()
OrderCycle.toggleProducts(exchange)
$scope.enterpriseFeesForEnterprise = (enterprise_id) ->
EnterpriseFee.forEnterprise(parseInt(enterprise_id))
@@ -59,6 +58,7 @@ angular.module('admin.orderCycles')
$scope.removeExchange = ($event, exchange) ->
$event.preventDefault()
OrderCycle.removeExchange(exchange)
$scope.order_cycle_form.$dirty = true
$scope.addCoordinatorFee = ($event) ->
$event.preventDefault()
@@ -81,4 +81,9 @@ angular.module('admin.orderCycles')
$scope.submit = ($event, destination) ->
$event.preventDefault()
StatusMessage.display 'progress', "Saving..."
OrderCycle.create(destination)
$scope.cancel = (destination) ->
$window.location = destination

View File

@@ -45,10 +45,6 @@ angular.module('admin.orderCycles')
$scope.enterprisesWithFees = ->
$scope.enterprises[id] for id in OrderCycle.participatingEnterpriseIds() when $scope.enterpriseFeesForEnterprise(id).length > 0
$scope.toggleProducts = ($event, exchange) ->
$event.preventDefault()
OrderCycle.toggleProducts(exchange)
$scope.enterpriseFeesForEnterprise = (enterprise_id) ->
EnterpriseFee.forEnterprise(parseInt(enterprise_id))

View File

@@ -1,4 +1,4 @@
angular.module('admin.orderCycles').controller "AdminSimpleCreateOrderCycleCtrl", ($scope, OrderCycle, Enterprise, EnterpriseFee, StatusMessage, ocInstance) ->
angular.module('admin.orderCycles').controller "AdminSimpleCreateOrderCycleCtrl", ($scope, $window, OrderCycle, Enterprise, EnterpriseFee, StatusMessage, ocInstance) ->
$scope.StatusMessage = StatusMessage
$scope.OrderCycle = OrderCycle
$scope.order_cycle = OrderCycle.new {coordinator_id: ocInstance.coordinator_id}, =>
@@ -7,6 +7,9 @@ angular.module('admin.orderCycles').controller "AdminSimpleCreateOrderCycleCtrl"
$scope.init(enterprises)
$scope.enterprise_fees = EnterpriseFee.index(coordinator_id: ocInstance.coordinator_id)
$scope.$watch 'order_cycle_form.$dirty', (newValue) ->
StatusMessage.display 'notice', 'You have unsaved changes' if newValue
$scope.init = (enterprises) ->
enterprise = enterprises[Object.keys(enterprises)[0]]
OrderCycle.addSupplier enterprise.id
@@ -43,5 +46,9 @@ angular.module('admin.orderCycles').controller "AdminSimpleCreateOrderCycleCtrl"
$scope.submit = ($event, destination) ->
$event.preventDefault()
StatusMessage.display 'progress', "Saving..."
OrderCycle.mirrorIncomingToOutgoingProducts()
OrderCycle.create(destination)
$scope.cancel = (destination) ->
$window.location = destination

View File

@@ -1,4 +1,4 @@
angular.module('admin.orderCycles').controller "AdminSimpleEditOrderCycleCtrl", ($scope, $location, OrderCycle, Enterprise, EnterpriseFee, StatusMessage) ->
angular.module('admin.orderCycles').controller "AdminSimpleEditOrderCycleCtrl", ($scope, $location, $window, OrderCycle, Enterprise, EnterpriseFee, StatusMessage) ->
$scope.orderCycleId = ->
$location.absUrl().match(/\/admin\/order_cycles\/(\d+)/)[1]
@@ -42,3 +42,6 @@ angular.module('admin.orderCycles').controller "AdminSimpleEditOrderCycleCtrl",
StatusMessage.display 'progress', "Saving..."
OrderCycle.mirrorIncomingToOutgoingProducts()
OrderCycle.update(destination, $scope.order_cycle_form)
$scope.cancel = (destination) ->
$window.location = destination

View File

@@ -1,4 +1,4 @@
angular.module('admin.orderCycles', ['ngResource', 'admin.utils', 'admin.indexUtils'])
angular.module('admin.orderCycles', ['ngResource', 'admin.utils', 'admin.indexUtils', 'ngTagsInput'])
.config ($httpProvider) ->
$httpProvider.defaults.headers.common['X-CSRF-Token'] = $('meta[name=csrf-token]').attr('content')

View File

@@ -1,4 +1,4 @@
angular.module('admin.orderCycles').factory 'OrderCycle', ($resource, $window, StatusMessage) ->
angular.module('admin.orderCycles').factory 'OrderCycle', ($resource, $window, StatusMessage, Panels) ->
OrderCycleResource = $resource '/admin/order_cycles/:action_name/:order_cycle_id.json', {}, {
'index': { method: 'GET', isArray: true}
'new' : { method: 'GET', params: { action_name: "new" } }
@@ -30,17 +30,19 @@ angular.module('admin.orderCycles').factory 'OrderCycle', ($resource, $window, S
exchangeDirection: (exchange) ->
if this.order_cycle.incoming_exchanges.indexOf(exchange) == -1 then 'outgoing' else 'incoming'
toggleProducts: (exchange) ->
exchange.showProducts = !exchange.showProducts
toggleAllProducts: (direction) ->
this.showProducts[direction] = !this.showProducts[direction]
exchange.showProducts = this.showProducts[direction] for exchange in this.exchangesByDirection(direction)
state = if this.showProducts[direction] then "open" else "closed"
exchanges = this.exchangesByDirection(direction)
Panels.toggle(exchange,'products',state) for exchange in exchanges
setExchangeVariants: (exchange, variants, selected) ->
direction = if exchange.incoming then "incoming" else "outgoing"
editable = @order_cycle["editable_variants_for_#{direction}_exchanges"][exchange.enterprise_id] || []
exchange.variants[variant] = selected for variant in variants when variant in editable
for variant in variants when variant in editable
exchange.variants[variant] = selected
@removeDistributionOfVariant(variant.id) if exchange.incoming
addSupplier: (new_supplier_id) ->
this.order_cycle.incoming_exchanges.push({enterprise_id: new_supplier_id, incoming: true, active: true, variants: {}, enterprise_fees: []})

View File

@@ -1,4 +1,2 @@
angular.module("admin.paymentMethods")
.controller "paymentMethodCtrl", ($scope, PaymentMethods) ->
$scope.findPaymentMethodByID = (id) ->
$scope.PaymentMethod = PaymentMethods.findByID(id)
angular.module("admin.paymentMethods").controller "paymentMethodCtrl", ($scope, paymentMethod) ->
$scope.paymentMethod = paymentMethod

View File

@@ -0,0 +1,3 @@
angular.module("admin.paymentMethods").controller "paymentMethodsCtrl", ($scope, PaymentMethods) ->
$scope.findPaymentMethodByID = (id) ->
$scope.PaymentMethod = PaymentMethods.findByID(id)

View File

@@ -1,7 +1,7 @@
angular.module("ofn.admin").controller "ProvidersCtrl", ($scope, paymentMethod) ->
angular.module("admin.paymentMethods").controller "ProvidersCtrl", ($scope, paymentMethod) ->
if paymentMethod.type
$scope.include_html = "/admin/payment_methods/show_provider_preferences?" +
"provider_type=#{paymentMethod.type};" +
"pm_id=#{paymentMethod.id};"
else
$scope.include_html = ""
$scope.include_html = ""

View File

@@ -1,7 +1,7 @@
angular.module("ofn.admin").directive "providerPrefsFor", ($http) ->
angular.module("admin.paymentMethods").directive "providerPrefsFor", ($http) ->
link: (scope, element, attrs) ->
element.on "change blur load", ->
scope.$apply ->
scope.include_html = "/admin/payment_methods/show_provider_preferences?" +
"provider_type=#{element.val()};" +
"pm_id=#{attrs.providerPrefsFor};"
"pm_id=#{attrs.providerPrefsFor};"

View File

@@ -1 +1 @@
angular.module("admin.paymentMethods", [])
angular.module("admin.paymentMethods", ['ngTagsInput', 'admin.utils', 'templates'])

View File

@@ -1,4 +1,3 @@
angular.module("admin.shippingMethods")
.controller "shippingMethodsCtrl", ($scope, ShippingMethods) ->
$scope.findShippingMethodByID = (id) ->
$scope.ShippingMethod = ShippingMethods.findByID(id)
angular.module("admin.shippingMethods").controller "shippingMethodsCtrl", ($scope, ShippingMethods) ->
$scope.findShippingMethodByID = (id) ->
$scope.ShippingMethod = ShippingMethods.findByID(id)

View File

@@ -1,15 +1,16 @@
angular.module("admin.tagRules").controller "TagRulesCtrl", ($scope, $http, enterprise) ->
angular.module("admin.tagRules").controller "TagRulesCtrl", ($scope, $http, $filter, enterprise) ->
$scope.tagGroups = enterprise.tag_groups
$scope.defaultTagGroup = enterprise.default_tag_group
$scope.visibilityOptions = [ { id: "visible", name: "VISIBLE" }, { id: "hidden", name: "NOT VISIBLE" } ]
updateRuleCounts = ->
index = 0
for tagGroup in $scope.tagGroups
$scope.updateRuleCounts = ->
index = $scope.defaultTagGroup.rules.length
for tagGroup in $filter('orderBy')($scope.tagGroups, 'position')
tagGroup.startIndex = index
index = index + tagGroup.rules.length
updateRuleCounts()
$scope.updateRuleCounts()
$scope.updateTagsRulesFor = (tagGroup) ->
for tagRule in tagGroup.rules
@@ -18,6 +19,7 @@ angular.module("admin.tagRules").controller "TagRulesCtrl", ($scope, $http, ente
$scope.addNewRuleTo = (tagGroup, ruleType) ->
newRule =
id: null
is_default: tagGroup == $scope.defaultTagGroup
preferred_customer_tags: (tag.text for tag in tagGroup.tags).join(",")
type: "TagRule::#{ruleType}"
switch ruleType
@@ -26,18 +28,28 @@ angular.module("admin.tagRules").controller "TagRulesCtrl", ($scope, $http, ente
when "FilterShippingMethods"
newRule.peferred_shipping_method_tags = []
newRule.preferred_matched_shipping_methods_visibility = "visible"
when "FilterPaymentMethods"
newRule.peferred_payment_method_tags = []
newRule.preferred_matched_payment_methods_visibility = "visible"
when "FilterProducts"
newRule.peferred_variant_tags = []
newRule.preferred_matched_variants_visibility = "visible"
when "FilterOrderCycles"
newRule.peferred_exchange_tags = []
newRule.preferred_matched_order_cycles_visibility = "visible"
tagGroup.rules.push(newRule)
updateRuleCounts()
$scope.enterprise_form.$setDirty()
$scope.updateRuleCounts()
$scope.addNewTag = ->
$scope.tagGroups.push { tags: [], rules: [] }
$scope.tagGroups.push { tags: [], rules: [], position: $scope.tagGroups.length + 1 }
$scope.deleteTagRule = (tagGroup, tagRule) ->
index = tagGroup.rules.indexOf(tagRule)
return unless index >= 0
if tagRule.id is null
tagGroup.rules.splice(index, 1)
updateRuleCounts()
$scope.updateRuleCounts()
else
if confirm("Are you sure?")
$http
@@ -45,4 +57,4 @@ angular.module("admin.tagRules").controller "TagRulesCtrl", ($scope, $http, ente
url: "/admin/enterprises/#{enterprise.id}/tag_rules/#{tagRule.id}.json"
.success ->
tagGroup.rules.splice(index, 1)
updateRuleCounts()
$scope.updateRuleCounts()

View File

@@ -1,28 +1,24 @@
angular.module("admin.tagRules").directive 'newTagRuleDialog', ($compile, $templateCache, $window) ->
angular.module("admin.tagRules").directive 'newTagRuleDialog', ($compile, $templateCache, DialogDefaults) ->
restrict: 'A'
scope: true
scope:
tagGroup: '='
addNewRuleTo: '='
link: (scope, element, attr) ->
# Compile modal template
template = $compile($templateCache.get('admin/new_tag_rule_dialog.html'))(scope)
scope.ruleTypes = [
# { id: "DiscountOrder", name: 'Apply a discount to orders' }
{ id: "FilterShippingMethods", name: 'Show/Hide shipping methods' }
{ id: "FilterProducts", name: 'Show or Hide variants in my shopfront' }
{ id: "FilterShippingMethods", name: 'Show or Hide shipping methods at checkout' }
{ id: "FilterPaymentMethods", name: 'Show or Hide payment methods at checkout' }
{ id: "FilterOrderCycles", name: 'Show or Hide order cycles in my shopfront' }
]
scope.ruleType = "DiscountOrder"
scope.ruleType = scope.ruleTypes[0].id
# Set Dialog options
template.dialog
show: { effect: "fade", duration: 400 }
hide: { effect: "fade", duration: 300 }
autoOpen: false
resizable: false
width: $window.innerWidth * 0.4;
modal: true
open: (event, ui) ->
$('.ui-widget-overlay').bind 'click', ->
$(this).siblings('.ui-dialog').find('.ui-dialog-content').dialog('close')
template.dialog(DialogDefaults)
# Link opening of dialog to click event on element
element.bind 'click', (e) ->

View File

@@ -1,4 +0,0 @@
angular.module("admin.tagRules").directive "discountOrder", ->
restrict: "E"
replace: true
templateUrl: "admin/tag_rules/discount_order.html"

View File

@@ -1,4 +0,0 @@
angular.module("admin.tagRules").directive "filterShippingMethods", ->
restrict: "E"
replace: true
templateUrl: "admin/tag_rules/filter_shipping_methods.html"

View File

@@ -0,0 +1,41 @@
angular.module("admin.tagRules").directive "tagRule", ->
restrict: "C"
templateUrl: "admin/tag_rules/tag_rule.html"
link: (scope, element, attrs) ->
scope.opt =
"TagRule::FilterShippingMethods":
textTop: "Shipping methods tagged"
textBottom: "are:"
taggable: "shipping_method"
tagsAttr: "shipping_method_tags"
tagListAttr: "preferred_shipping_method_tags"
inputTemplate: "admin/tag_rules/filter_shipping_methods_input.html"
tagListFor: (rule) ->
rule.preferred_shipping_method_tags
"TagRule::FilterPaymentMethods":
textTop: "Payment methods tagged"
textBottom: "are:"
taggable: "payment_method"
tagsAttr: "payment_method_tags"
tagListAttr: "preferred_payment_method_tags"
inputTemplate: "admin/tag_rules/filter_payment_methods_input.html"
tagListFor: (rule) ->
rule.preferred_payment_method_tags
"TagRule::FilterOrderCycles":
textTop: "Order Cycles tagged"
textBottom: "are:"
taggable: "exchange"
tagsAttr: "exchange_tags"
tagListAttr: "preferred_exchange_tags"
inputTemplate: "admin/tag_rules/filter_order_cycles_input.html"
tagListFor: (rule) ->
rule.preferred_exchange_tags
"TagRule::FilterProducts":
textTop: "Inventory variants tagged"
textBottom: "are:"
taggable: "variant"
tagsAttr: "variant_tags"
tagListAttr: "preferred_variant_tags"
inputTemplate: "admin/tag_rules/filter_products_input.html"
tagListFor: (rule) ->
rule.preferred_variant_tags

View File

@@ -0,0 +1,17 @@
angular.module("admin.utils").directive 'helpModal', ($compile, $templateCache, $window, DialogDefaults) ->
restrict: 'C'
scope:
template: '@'
link: (scope, element, attr) ->
# Compile modal template
template = $compile($templateCache.get(scope.template))(scope)
# Load Dialog Options
template.dialog(DialogDefaults)
# Link opening of dialog to click event on element
element.bind 'click', (e) -> template.dialog('open')
scope.close = ->
template.dialog('close')
return

View File

@@ -0,0 +1,37 @@
angular.module("admin.utils").directive "ofnSortable", ($timeout, $parse) ->
restrict: "E"
scope:
items: '@'
position: '@'
afterSort: '&'
handle: "@"
axis: "@"
link: (scope, element, attrs) ->
$timeout ->
scope.axis ||= "y"
scope.handle ||= ".handle"
getScopePos = $parse(scope.position)
setScopePos = getScopePos.assign
element.sortable
handle: scope.handle
helper: 'clone'
axis: scope.axis
items: scope.items
appendTo: element
update: (event, ui) ->
scope.$apply ->
sortableSiblings = ($(ss) for ss in ui.item.siblings(scope.items))
offset = Math.min(ui.item.index(), sortableSiblings[0].index())
newPos = ui.item.index() - offset + 1
oldPos = getScopePos(ui.item.scope())
if newPos < oldPos
for sibScope in sortableSiblings.map((ss) -> ss.scope())
pos = getScopePos(sibScope)
setScopePos(sibScope, pos + 1) if pos >= newPos && pos < oldPos
else if newPos > oldPos
for sibScope in sortableSiblings.map((ss) -> ss.scope())
pos = getScopePos(sibScope)
setScopePos(sibScope, pos - 1) if pos > oldPos && pos <= newPos
setScopePos(ui.item.scope(), newPos)
scope.afterSort()

View File

@@ -6,11 +6,32 @@ angular.module("admin.utils").directive "tagsWithTranslation", ($timeout) ->
tagsAttr: "@?"
tagListAttr: "@?"
findTags: "&"
form: '=?'
onTagAdded: "&"
onTagRemoved: "&"
max: "="
link: (scope, element, attrs) ->
scope.findTags = undefined unless attrs.hasOwnProperty("findTags")
scope.limitReached = false
compileTagList = ->
scope.limitReached = scope.object[scope.tagsAttr].length >= scope.max if scope.max != undefined
scope.object[scope.tagListAttr] = (tag.text for tag in scope.object[scope.tagsAttr]).join(",")
$timeout ->
# Initialize properties if necessary
scope.tagsAttr ||= "tags"
scope.tagListAttr ||= "tag_list"
scope.object[scope.tagsAttr] ||= []
compileTagList()
watchString = "object.#{scope.tagsAttr}"
scope.$watchCollection watchString, ->
scope.object[scope.tagListAttr] = (tag.text for tag in scope.object[scope.tagsAttr]).join(",")
scope.tagAdded = ->
scope.onTagAdded()
compileTagList()
scope.tagRemoved = ->
# For some reason the tags input doesn't mark the form
# as dirty when a tag is removed, which breaks the save bar
scope.form.$setDirty(true) if typeof scope.form isnt 'undefined'
scope.onTagRemoved()
compileTagList()

View File

@@ -0,0 +1,10 @@
angular.module("admin.utils").factory "DialogDefaults", ($window) ->
show: { effect: "fade", duration: 400 }
hide: { effect: "fade", duration: 300 }
autoOpen: false
resizable: false
width: $window.innerWidth * 0.4;
modal: true
open: (event, ui) ->
$('.ui-widget-overlay').bind 'click', ->
$(this).siblings('.ui-dialog').find('.ui-dialog-content').dialog('close')

View File

@@ -0,0 +1,12 @@
angular.module("admin.customers").factory 'InfoDialog', ($rootScope, $compile, $injector, $templateCache, DialogDefaults) ->
new class InfoDialog
open: (type, message) ->
scope = $rootScope.$new()
scope.message = message
scope.dialog_class = type
template = $compile($templateCache.get('admin/info_dialog.html'))(scope)
template.dialog(DialogDefaults)
template.dialog('open')
scope.close = ->
template.dialog('close')
null

View File

@@ -1 +1 @@
angular.module("admin.utils", ["ngSanitize"])
angular.module("admin.utils", ["templates", "ngSanitize"])

View File

@@ -6,7 +6,6 @@ angular.module("admin.variantOverrides").directive "trackInheritance", (VariantO
ngModel.$parsers.push (viewValue) ->
if ngModel.$dirty && viewValue
variantOverride = VariantOverrides.inherit(scope.hub_id, scope.variant.id)
DirtyVariantOverrides.add variantOverride
DirtyVariantOverrides.inherit scope.hub_id, scope.variant.id, scope.variantOverrides[scope.hub_id][scope.variant.id].id
scope.displayDirty()
viewValue

View File

@@ -0,0 +1,9 @@
angular.module("admin.variantOverrides").directive "trackTagList", (VariantOverrides, DirtyVariantOverrides) ->
link: (scope, element, attrs) ->
watchString = "variantOverrides[#{scope.hub_id}][#{scope.variant.id}].tag_list"
scope.$watch watchString, (newValue, oldValue) ->
if typeof newValue isnt 'undefined' && newValue != oldValue
scope.inherit = false
vo_id = scope.variantOverrides[scope.hub_id][scope.variant.id].id
DirtyVariantOverrides.set scope.hub_id, scope.variant.id, vo_id, 'tag_list', newValue
scope.displayDirty()

Some files were not shown because too many files have changed in this diff Show More