mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-26 01:33:22 +00:00
Merge branch 'master' into 2-0-stable-oct
This commit is contained in:
@@ -61,7 +61,7 @@
|
||||
//= require moment/nb.js
|
||||
//= require moment/pt-br.js
|
||||
//= require moment/sv.js
|
||||
//= require ../shared/mm-foundation-tpls-0.8.0.min.js
|
||||
//= require ../shared/mm-foundation-tpls-0.9.0-20180826174721.min.js
|
||||
//= require angularjs-file-upload
|
||||
|
||||
//= require_tree .
|
||||
|
||||
@@ -8,8 +8,8 @@ angular.module("admin.enterprise_groups")
|
||||
{ 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" }
|
||||
{ name: 'contact', label: t('admin_enterprise_groups_contact'), icon_class: "icon-phone" }
|
||||
{ name: 'web', label: t('admin_enterprise_groups_web'), icon_class: "icon-globe" }
|
||||
]
|
||||
|
||||
$scope.select(0)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
angular.module("admin.enterprises")
|
||||
.controller "enterpriseCtrl", ($scope, $http, $window, NavigationCheck, enterprise, EnterprisePaymentMethods, EnterpriseShippingMethods, SideMenu, StatusMessage) ->
|
||||
.controller "enterpriseCtrl", ($scope, $http, $window, NavigationCheck, enterprise, Enterprises, EnterprisePaymentMethods, EnterpriseShippingMethods, SideMenu, StatusMessage) ->
|
||||
$scope.Enterprise = enterprise
|
||||
$scope.PaymentMethods = EnterprisePaymentMethods.paymentMethods
|
||||
$scope.ShippingMethods = EnterpriseShippingMethods.shippingMethods
|
||||
@@ -67,3 +67,27 @@ angular.module("admin.enterprises")
|
||||
|
||||
$scope.resetModal = ->
|
||||
$scope.newUser = $scope.invite_errors = $scope.invite_success = null
|
||||
|
||||
$scope.removeLogo = ->
|
||||
return unless confirm(t("admin.enterprises.remove_logo.immediate_removal_warning"))
|
||||
|
||||
Enterprises.removeLogo($scope.Enterprise).then (data) ->
|
||||
$scope.Enterprise = angular.copy(data)
|
||||
$scope.$emit("enterprise:updated", $scope.Enterprise)
|
||||
|
||||
StatusMessage.display("success", t("admin.enterprises.remove_logo.removed_successfully"))
|
||||
, (response) ->
|
||||
if response.data.error?
|
||||
StatusMessage.display("failure", response.data.error)
|
||||
|
||||
$scope.removePromoImage = ->
|
||||
return unless confirm(t("admin.enterprises.remove_promo_image.immediate_removal_warning"))
|
||||
|
||||
Enterprises.removePromoImage($scope.Enterprise).then (data) ->
|
||||
$scope.Enterprise = angular.copy(data)
|
||||
$scope.$emit("enterprise:updated", $scope.Enterprise)
|
||||
|
||||
StatusMessage.display("success", t("admin.enterprises.remove_promo_image.removed_successfully"))
|
||||
, (response) ->
|
||||
if response.data.error?
|
||||
StatusMessage.display("failure", response.data.error)
|
||||
|
||||
@@ -3,8 +3,12 @@ angular.module("admin.orderCycles").controller "OrderCyclesCtrl", ($scope, $q, C
|
||||
$scope.columns = Columns.columns
|
||||
$scope.saveAll = -> OrderCycles.saveChanges($scope.order_cycles_form)
|
||||
$scope.ordersCloseAtLimit = -31 # days
|
||||
$scope.involvingFilter = 0
|
||||
$scope.scheduleFilter = 0
|
||||
|
||||
$scope.resetSelectFilters = ->
|
||||
$scope.scheduleFilter = 0
|
||||
$scope.involvingFilter = 0
|
||||
$scope.query = ''
|
||||
$scope.resetSelectFilters()
|
||||
|
||||
compileData = ->
|
||||
for schedule in $scope.schedules
|
||||
|
||||
@@ -156,7 +156,7 @@ angular.module('admin.orderCycles').factory 'OrderCycle', ($resource, $window, S
|
||||
if response.data.errors?
|
||||
StatusMessage.display('failure', response.data.errors[0])
|
||||
else
|
||||
StatusMessage.display('failure', 'Failed to create order cycle')
|
||||
StatusMessage.display('failure', t('js.order_cycles.create_failure'))
|
||||
|
||||
update: (destination, form) ->
|
||||
return unless @confirmNoDistributors()
|
||||
@@ -171,7 +171,7 @@ angular.module('admin.orderCycles').factory 'OrderCycle', ($resource, $window, S
|
||||
if response.data.errors?
|
||||
StatusMessage.display('failure', response.data.errors[0])
|
||||
else
|
||||
StatusMessage.display('failure', 'Failed to create order cycle')
|
||||
StatusMessage.display('failure', t('js.order_cycles.update_failure'))
|
||||
|
||||
|
||||
confirmNoDistributors: ->
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
angular.module("admin.orders").controller "orderCtrl", ($scope, shops, orderCycles, $compile, $attrs, Orders) ->
|
||||
$scope.$compile = $compile
|
||||
$scope.shops = shops
|
||||
$scope.orderCycles = orderCycles
|
||||
|
||||
$scope.distributor_id = parseInt($attrs.ofnDistributorId)
|
||||
$scope.order_cycle_id = parseInt($attrs.ofnOrderCycleId)
|
||||
|
||||
$scope.validOrderCycle = (oc) ->
|
||||
$scope.orderCycleHasDistributor oc, parseInt($scope.distributor_id)
|
||||
|
||||
$scope.distributorHasOrderCycles = (distributor) ->
|
||||
(oc for oc in $scope.orderCycles when @orderCycleHasDistributor(oc, distributor.id)).length > 0
|
||||
|
||||
$scope.orderCycleHasDistributor = (oc, distributor_id) ->
|
||||
distributor_ids = (d.id for d in oc.distributors)
|
||||
distributor_ids.indexOf(distributor_id) != -1
|
||||
|
||||
$scope.distributionChosen = ->
|
||||
$scope.distributor_id && $scope.order_cycle_id
|
||||
|
||||
for oc in $scope.orderCycles
|
||||
oc.name_and_status = "#{oc.name} (#{oc.status})"
|
||||
|
||||
for shop in $scope.shops
|
||||
shop.disabled = !$scope.distributorHasOrderCycles(shop)
|
||||
@@ -1,26 +1,47 @@
|
||||
angular.module("admin.orders").controller "ordersCtrl", ($scope, $compile, $attrs, shops, orderCycles) ->
|
||||
$scope.$compile = $compile
|
||||
$scope.shops = shops
|
||||
$scope.orderCycles = orderCycles
|
||||
angular.module("admin.orders").controller "ordersCtrl", ($scope, RequestMonitor, Orders, SortOptions) ->
|
||||
$scope.RequestMonitor = RequestMonitor
|
||||
$scope.pagination = Orders.pagination
|
||||
$scope.orders = Orders.all
|
||||
$scope.sortOptions = SortOptions
|
||||
$scope.per_page_options = [
|
||||
{id: 15, name: t('js.admin.orders.index.per_page', results: 15)},
|
||||
{id: 50, name: t('js.admin.orders.index.per_page', results: 50)},
|
||||
{id: 100, name: t('js.admin.orders.index.per_page', results: 100)}
|
||||
]
|
||||
|
||||
$scope.distributor_id = parseInt($attrs.ofnDistributorId)
|
||||
$scope.order_cycle_id = parseInt($attrs.ofnOrderCycleId)
|
||||
$scope.initialise = ->
|
||||
$scope.per_page = 15
|
||||
$scope.q = {
|
||||
completed_at_not_null: true
|
||||
}
|
||||
$scope.fetchResults()
|
||||
|
||||
$scope.validOrderCycle = (oc) ->
|
||||
$scope.orderCycleHasDistributor oc, parseInt($scope.distributor_id)
|
||||
$scope.fetchResults = (page=1) ->
|
||||
Orders.index({
|
||||
'q[created_at_lt]': $scope['q']['created_at_lt'],
|
||||
'q[created_at_gt]': $scope['q']['created_at_gt'],
|
||||
'q[state_eq]': $scope['q']['state_eq'],
|
||||
'q[number_cont]': $scope['q']['number_cont'],
|
||||
'q[email_cont]': $scope['q']['email_cont'],
|
||||
'q[bill_address_firstname_start]': $scope['q']['bill_address_firstname_start'],
|
||||
'q[bill_address_lastname_start]': $scope['q']['bill_address_lastname_start'],
|
||||
'q[completed_at_not_null]': $scope['q']['completed_at_not_null'],
|
||||
'q[inventory_units_shipment_id_null]': $scope['q']['inventory_units_shipment_id_null'],
|
||||
'q[distributor_id_in]': $scope['q']['distributor_id_in'],
|
||||
'q[order_cycle_id_in]': $scope['q']['order_cycle_id_in'],
|
||||
'q[order_cycle_id_in]': $scope['q']['order_cycle_id_in'],
|
||||
'q[s]': $scope.sorting || 'id desc',
|
||||
per_page: $scope.per_page,
|
||||
page: page
|
||||
})
|
||||
|
||||
$scope.distributorHasOrderCycles = (distributor) ->
|
||||
(oc for oc in orderCycles when @orderCycleHasDistributor(oc, distributor.id)).length > 0
|
||||
$scope.$watch 'sortOptions', (sort) ->
|
||||
if sort && sort.predicate != ""
|
||||
$scope.sorting = sort.predicate + ' desc' if sort.reverse
|
||||
$scope.sorting = sort.predicate + ' asc' if !sort.reverse
|
||||
$scope.fetchResults()
|
||||
, true
|
||||
|
||||
$scope.orderCycleHasDistributor = (oc, distributor_id) ->
|
||||
distributor_ids = (d.id for d in oc.distributors)
|
||||
distributor_ids.indexOf(distributor_id) != -1
|
||||
|
||||
$scope.distributionChosen = ->
|
||||
$scope.distributor_id && $scope.order_cycle_id
|
||||
|
||||
for oc in $scope.orderCycles
|
||||
oc.name_and_status = "#{oc.name} (#{oc.status})"
|
||||
|
||||
for shop in $scope.shops
|
||||
shop.disabled = !$scope.distributorHasOrderCycles(shop)
|
||||
$scope.changePage = (newPage) ->
|
||||
$scope.page = newPage
|
||||
$scope.fetchResults(newPage)
|
||||
|
||||
@@ -51,7 +51,7 @@ angular.module("admin.productImport").controller "ImportFormCtrl", ($scope, $htt
|
||||
$scope.start = () ->
|
||||
$scope.started = true
|
||||
total = ams_data.item_count
|
||||
size = 100
|
||||
size = 50
|
||||
$scope.chunks = Math.ceil(total / size)
|
||||
|
||||
i = 0
|
||||
|
||||
@@ -10,7 +10,7 @@ angular.module("admin.productImport").filter 'entriesFilterValid', ->
|
||||
|
||||
if type == 'valid' and validates_as != '' \
|
||||
or type == 'invalid' and validates_as == '' \
|
||||
or type == 'create_product' and validates_as == 'new_product' or validates_as == 'new_variant' \
|
||||
or type == 'create_product' and (validates_as == 'new_product' or validates_as == 'new_variant') \
|
||||
or type == 'update_product' and validates_as == 'existing_variant' \
|
||||
or type == 'create_inventory' and validates_as == 'new_inventory_item' \
|
||||
or type == 'update_inventory' and validates_as == 'existing_inventory_item'
|
||||
|
||||
@@ -8,4 +8,10 @@ angular.module("admin.resources").factory 'EnterpriseResource', ($resource) ->
|
||||
isArray: true
|
||||
'update':
|
||||
method: 'PUT'
|
||||
'removeLogo':
|
||||
url: '/api/enterprises/:id/logo.json'
|
||||
method: 'DELETE'
|
||||
'removePromoImage':
|
||||
url: '/api/enterprises/:id/promo_image.json'
|
||||
method: 'DELETE'
|
||||
})
|
||||
|
||||
@@ -2,7 +2,6 @@ angular.module("admin.resources").factory 'OrderResource', ($resource) ->
|
||||
$resource('/admin/orders/:id/:action.json', {}, {
|
||||
'index':
|
||||
method: 'GET'
|
||||
isArray: true
|
||||
'update':
|
||||
method: 'PUT'
|
||||
})
|
||||
|
||||
@@ -38,3 +38,17 @@ angular.module("admin.resources").factory 'Enterprises', ($q, EnterpriseResource
|
||||
|
||||
resetAttribute: (enterprise, attribute) ->
|
||||
enterprise[attribute] = @pristineByID[enterprise.id][attribute]
|
||||
|
||||
performActionOnEnterpriseResource = (resourceAction) ->
|
||||
(enterprise) ->
|
||||
deferred = $q.defer()
|
||||
resourceAction({id: enterprise.permalink}, ((data) =>
|
||||
@pristineByID[enterprise.id] = angular.copy(data)
|
||||
deferred.resolve(data)
|
||||
), ((response) ->
|
||||
deferred.reject(response)
|
||||
))
|
||||
deferred.promise
|
||||
|
||||
removeLogo: performActionOnEnterpriseResource(EnterpriseResource.removeLogo)
|
||||
removePromoImage: performActionOnEnterpriseResource(EnterpriseResource.removePromoImage)
|
||||
|
||||
@@ -1,18 +1,30 @@
|
||||
angular.module("admin.resources").factory 'Orders', ($q, OrderResource) ->
|
||||
angular.module("admin.resources").factory 'Orders', ($q, OrderResource, RequestMonitor) ->
|
||||
new class Orders
|
||||
all: []
|
||||
byID: {}
|
||||
pristineByID: {}
|
||||
pagination: {}
|
||||
|
||||
index: (params={}, callback=null) ->
|
||||
OrderResource.index params, (data) =>
|
||||
request = OrderResource.index params, (data) =>
|
||||
@load(data)
|
||||
(callback || angular.noop)(data)
|
||||
RequestMonitor.load(request.$promise)
|
||||
@all
|
||||
|
||||
load: (orders) ->
|
||||
for order in orders
|
||||
load: (data) ->
|
||||
angular.extend(@pagination, data.pagination)
|
||||
@clearData()
|
||||
for order in data.orders
|
||||
@all.push order
|
||||
@byID[order.id] = order
|
||||
@pristineByID[order.id] = angular.copy(order)
|
||||
|
||||
clearData: ->
|
||||
@all.length = 0
|
||||
@byID = {}
|
||||
@pristineByID = {}
|
||||
|
||||
save: (order) ->
|
||||
deferred = $q.defer()
|
||||
order.$update({id: order.number})
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#= require lodash.underscore.js
|
||||
#= require angular-scroll.min.js
|
||||
#= require angular-google-maps.min.js
|
||||
#= require ../shared/mm-foundation-tpls-0.8.0.min.js
|
||||
#= require ../shared/mm-foundation-tpls-0.9.0-20180826174721.min.js
|
||||
#= require ../shared/ng-infinite-scroll.min.js
|
||||
#= require ../shared/angular-local-storage.js
|
||||
#= require ../shared/angular-slideables.js
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
.row
|
||||
.large-9.columns
|
||||
%p
|
||||
{{ 'legal.cookies_banner.cookies_usage' | t}}
|
||||
%p
|
||||
{{ 'legal.cookies_banner.cookies_desc' | t}}
|
||||
%p
|
||||
{{ 'legal.cookies_banner.cookies_policy_link_desc' | t}}
|
||||
-#
|
||||
%a{ 'cookies-policy-modal'=> true}
|
||||
{{ 'legal.cookies_banner.cookies_policy_link' | t}}
|
||||
|
||||
.large-3.columns
|
||||
%button{ng: { controller:"CookiesBannerCtrl", click: "acceptCookies()" }}
|
||||
{{ 'legal.cookies_banner.cookies_accept_button' | t}}
|
||||
@@ -1,6 +0,0 @@
|
||||
Darkswarm.controller "CookiesBannerCtrl", ($scope, CookiesBannerService, $http, $window)->
|
||||
|
||||
$scope.acceptCookies = ->
|
||||
$http.post('/api/cookies/consent')
|
||||
CookiesBannerService.close()
|
||||
CookiesBannerService.disable()
|
||||
@@ -1,6 +0,0 @@
|
||||
Darkswarm.directive 'cookiesBanner', (CookiesBannerService) ->
|
||||
restrict: 'A'
|
||||
link: (scope, elm, attr)->
|
||||
return if not attr.cookiesBanner? || attr.cookiesBanner == 'false'
|
||||
CookiesBannerService.enable()
|
||||
CookiesBannerService.open()
|
||||
@@ -1,23 +0,0 @@
|
||||
Darkswarm.factory "CookiesBannerService", (Navigation, $modal, $location, Redirections, Loading)->
|
||||
|
||||
new class CookiesBannerService
|
||||
modalMessage: null
|
||||
isEnabled: false
|
||||
|
||||
open: (path, template = 'darkswarm/cookies_banner/cookies_banner.html') =>
|
||||
return unless @isEnabled
|
||||
@modalInstance = $modal.open
|
||||
templateUrl: template
|
||||
windowClass: "cookies-banner full"
|
||||
backdrop: 'static'
|
||||
keyboard: false
|
||||
|
||||
close: =>
|
||||
return unless @isEnabled
|
||||
@modalInstance.close()
|
||||
|
||||
enable: =>
|
||||
@isEnabled = true
|
||||
|
||||
disable: =>
|
||||
@isEnabled = false
|
||||
@@ -1,3 +0,0 @@
|
||||
Darkswarm.controller "CookiesPolicyModalCtrl", ($scope, $window)->
|
||||
|
||||
$scope.instance_hostname = $window.location.hostname
|
||||
@@ -1,5 +0,0 @@
|
||||
Darkswarm.directive 'cookiesPolicyModal', (CookiesPolicyModalService) ->
|
||||
restrict: 'A'
|
||||
link: (scope, elem, attrs) ->
|
||||
elem.bind "click", ->
|
||||
CookiesPolicyModalService.open ''
|
||||
@@ -1,30 +0,0 @@
|
||||
Darkswarm.factory "CookiesPolicyModalService", (Navigation, $modal, $location, CookiesBannerService)->
|
||||
|
||||
new class CookiesPolicyModalService
|
||||
defaultPath: "/policies/cookies"
|
||||
modalMessage: null
|
||||
|
||||
constructor: ->
|
||||
if $location.path() is @defaultPath || location.pathname is @defaultPath
|
||||
@open ''
|
||||
|
||||
open: (path = false, template = 'angular-templates/cookies_policy.html') =>
|
||||
@modalInstance = $modal.open
|
||||
templateUrl: template
|
||||
windowClass: "cookies-policy-modal medium"
|
||||
|
||||
@closeCookiesBanner()
|
||||
@onCloseReOpenCookiesBanner()
|
||||
|
||||
selectedPath = path || @defaultPath
|
||||
Navigation.navigate selectedPath
|
||||
|
||||
closeCookiesBanner: =>
|
||||
setTimeout ->
|
||||
CookiesBannerService.close()
|
||||
, 200
|
||||
|
||||
onCloseReOpenCookiesBanner: =>
|
||||
@modalInstance.result.then(
|
||||
-> CookiesBannerService.open(),
|
||||
-> CookiesBannerService.open() )
|
||||
File diff suppressed because one or more lines are too long
10
app/assets/javascripts/shared/mm-foundation-tpls-0.9.0-20180826174721.min.js
vendored
Normal file
10
app/assets/javascripts/shared/mm-foundation-tpls-0.9.0-20180826174721.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@@ -1,12 +0,0 @@
|
||||
// This is a manifest file that'll be compiled into including all the files listed below.
|
||||
// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
|
||||
// be included in the compiled file accessible from http://example.com/assets/application.js
|
||||
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
||||
// the compiled file.
|
||||
//
|
||||
|
||||
//= require 'jquery'
|
||||
//= require store/spree_frontend
|
||||
//= require store/spree_auth
|
||||
|
||||
//= require_tree .
|
||||
@@ -4,6 +4,9 @@
|
||||
.large-12.columns
|
||||
.alert-box.success{ng: {show: 'messages != null'}}
|
||||
{{ messages }}
|
||||
.large-12.columns
|
||||
.alert-box.alert{ng: {show: 'errors.message != null'}}
|
||||
{{ errors.message }}
|
||||
.row
|
||||
.large-12.columns
|
||||
%label{for: "email"} {{'signup_email' | t}}
|
||||
|
||||
Reference in New Issue
Block a user