mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-29 21:17:17 +00:00
Merging master branch into require_standard_variant
This commit is contained in:
@@ -4,13 +4,15 @@ angular.module("ofn.admin").controller "AdminProductEditCtrl", ($scope, $timeout
|
||||
$scope.StatusMessage = StatusMessage
|
||||
|
||||
$scope.columns =
|
||||
producer: {name: "Producer", visible: true}
|
||||
name: {name: "Name", visible: true}
|
||||
unit: {name: "Unit", visible: true}
|
||||
price: {name: "Price", visible: true}
|
||||
on_hand: {name: "On Hand", visible: true}
|
||||
category: {name: "Category", visible: false}
|
||||
available_on: {name: "Available On", visible: false}
|
||||
producer: {name: "Producer", visible: true}
|
||||
sku: {name: "SKU", visible: false}
|
||||
name: {name: "Name", visible: true}
|
||||
unit: {name: "Unit", visible: true}
|
||||
price: {name: "Price", visible: true}
|
||||
on_hand: {name: "On Hand", visible: true}
|
||||
category: {name: "Category", visible: false}
|
||||
inherits_properties: {name: "Inherits Properties?", visible: false}
|
||||
available_on: {name: "Available On", visible: false}
|
||||
|
||||
$scope.variant_unit_options = VariantUnitManager.variantUnitOptions()
|
||||
|
||||
@@ -288,6 +290,9 @@ filterSubmitProducts = (productsToFilter) ->
|
||||
filteredMaster ?= { id: product.master.id }
|
||||
filteredMaster.display_as = product.master.display_as
|
||||
|
||||
if product.hasOwnProperty("sku")
|
||||
filteredProduct.sku = product.sku
|
||||
hasUpdatableProperty = true
|
||||
if product.hasOwnProperty("name")
|
||||
filteredProduct.name = product.name
|
||||
hasUpdatableProperty = true
|
||||
@@ -310,6 +315,9 @@ filterSubmitProducts = (productsToFilter) ->
|
||||
if product.hasOwnProperty("category_id")
|
||||
filteredProduct.primary_taxon_id = product.category_id
|
||||
hasUpdatableProperty = true
|
||||
if product.hasOwnProperty("inherits_properties")
|
||||
filteredProduct.inherits_properties = product.inherits_properties
|
||||
hasUpdatableProperty = true
|
||||
if product.hasOwnProperty("available_on")
|
||||
filteredProduct.available_on = product.available_on
|
||||
hasUpdatableProperty = true
|
||||
|
||||
@@ -6,10 +6,10 @@ Darkswarm.directive "activeSelector", ->
|
||||
replace: true
|
||||
templateUrl: 'active_selector.html'
|
||||
link: (scope, elem, attr)->
|
||||
scope.selector.emit = scope.emit
|
||||
elem.bind "click", ->
|
||||
scope.$apply ->
|
||||
scope.selector.active = !scope.selector.active
|
||||
# This function is a convention, e.g. a callback on the scope applied when active changes
|
||||
scope.emit() if scope.emit
|
||||
|
||||
unless scope.readOnly && scope.readOnly()
|
||||
scope.selector.emit = scope.emit
|
||||
elem.bind "click", ->
|
||||
scope.$apply ->
|
||||
scope.selector.active = !scope.selector.active
|
||||
# This function is a convention, e.g. a callback on the scope applied when active changes
|
||||
scope.emit() if scope.emit
|
||||
|
||||
@@ -5,7 +5,7 @@ Darkswarm.directive "filterSelector", (FilterSelectorsService)->
|
||||
replace: true
|
||||
scope:
|
||||
objects: "&"
|
||||
activeSelectors: "="
|
||||
activeSelectors: "=?"
|
||||
allSelectors: "=?" # Optional
|
||||
templateUrl: "filter_selector.html"
|
||||
|
||||
@@ -13,6 +13,9 @@ Darkswarm.directive "filterSelector", (FilterSelectorsService)->
|
||||
selectors_by_id = {}
|
||||
selectors = null # To get scoping/closure right
|
||||
|
||||
scope.readOnly = ->
|
||||
!attr.activeSelectors?
|
||||
|
||||
scope.emit = ->
|
||||
scope.activeSelectors = selectors.filter (selector)->
|
||||
selector.active
|
||||
@@ -23,10 +26,10 @@ Darkswarm.directive "filterSelector", (FilterSelectorsService)->
|
||||
# when data has been loaded, in order to pass
|
||||
# selectors up
|
||||
scope.$on 'loadFilterSelectors', ->
|
||||
scope.allSelectors = scope.selectors()
|
||||
scope.allSelectors = scope.selectors() if attr.allSelectors?
|
||||
|
||||
scope.$watchCollection "selectors()", (newValue, oldValue) ->
|
||||
scope.allSelectors = scope.selectors()
|
||||
scope.allSelectors = scope.selectors() if attr.allSelectors?
|
||||
|
||||
# Build a list of selectors
|
||||
scope.selectors = ->
|
||||
|
||||
@@ -4,6 +4,7 @@ Darkswarm.directive 'singleLineSelectors', ($timeout, $filter) ->
|
||||
scope:
|
||||
objects: "&"
|
||||
activeSelectors: "="
|
||||
selectorName: "@activeSelectors"
|
||||
link: (scope,element,attrs) ->
|
||||
scope.fitting = false
|
||||
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
Darkswarm.filter 'propertiesWithValuesOf', ->
|
||||
(objects)->
|
||||
propertiesWithValues = {}
|
||||
for object in objects
|
||||
for property in object.properties_with_values
|
||||
propertiesWithValues[property.id] = property
|
||||
propertiesWithValues
|
||||
@@ -21,6 +21,8 @@ Darkswarm.factory 'Products', ($resource, Enterprises, Dereferencer, Taxons, Pro
|
||||
for product in @products
|
||||
product.supplier = Enterprises.enterprises_by_id[product.supplier.id]
|
||||
Dereferencer.dereference product.taxons, Taxons.taxons_by_id
|
||||
|
||||
product.properties = angular.copy(product.properties_with_values)
|
||||
Dereferencer.dereference product.properties, Properties.properties_by_id
|
||||
|
||||
# May return different objects! If the variant has already been registered
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
%li{ ng: { class: "{active: selector.active}" } }
|
||||
%a{ ng: { transclude: true, class: "{active: selector.active}" } }
|
||||
%a{ "tooltip" => "{{selector.object.value}}", "tooltip-placement" => "bottom",
|
||||
ng: { transclude: true, class: "{active: selector.active, 'has-tip': selector.object.value}" } }
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
%active-selector{ ng: { repeat: "selector in selectors()", show: "ifDefined(selector.fits, true)" } }
|
||||
%render-svg{path: "{{selector.object.icon}}", ng: { if: "selector.object.icon"} }
|
||||
%span {{ selector.object.name }}
|
||||
%div{ style: "display: inline-block" }
|
||||
%active-selector{ ng: { repeat: "selector in selectors()", show: "ifDefined(selector.fits, true)" } }
|
||||
%render-svg{path: "{{selector.object.icon}}", ng: { if: "selector.object.icon"} }
|
||||
%span {{ selector.object.name }}
|
||||
|
||||
@@ -6,24 +6,15 @@
|
||||
%em from
|
||||
%span.avenir {{ enterprise.name }}
|
||||
|
||||
%br
|
||||
|
||||
-# TODO: Add product taxons and properties here
|
||||
-# / TODO: Rob - add in taxons and properties and property pop-overs
|
||||
-# / %render-svg{path: "{{product.primary_taxon.icon}}"}
|
||||
-# .pad-top
|
||||
-# %span.filter-shopfront.taxon-selectors
|
||||
-# %ul.inline-block
|
||||
-# %li
|
||||
-# %a.button.tiny.disabled Grains
|
||||
-# %li
|
||||
-# %a.button.tiny.disabled Dairy
|
||||
-#
|
||||
-# %span.filter-shopfront.property-selectors.pad-top
|
||||
-# %ul.inline-block
|
||||
-# %li
|
||||
-# %a.button.tiny Organic certified
|
||||
-# / TODO: Rob - need popover, use will's directive or this? http://pineconellc.github.io/angular-foundation/
|
||||
.filter-shopfront.taxon-selectors.inline-block
|
||||
%ul
|
||||
%filter-selector{ objects: "[product] | taxonsOf" }
|
||||
|
||||
.filter-shopfront.property-selectors.inline-block
|
||||
%ul
|
||||
%filter-selector{ objects: "[product] | propertiesWithValuesOf" }
|
||||
|
||||
%div{"ng-if" => "product.description"}
|
||||
%hr
|
||||
|
||||
@@ -3,12 +3,12 @@
|
||||
%filter-selector{objects: "objects()", "active-selectors" => "activeSelectors", "all-selectors" => "allSelectors" }
|
||||
|
||||
%li.more{ ng: { show: "overFlowSelectors().length > 0 || fitting" } }
|
||||
%a.dropdown{ data: { dropdown: "show-more" }, ng: { class: "{active: selectedOverFlowSelectors().length > 0}" } }
|
||||
%a.dropdown{ data: { dropdown: "{{ 'show-more-' + selectorName }}" }, ng: { class: "{active: selectedOverFlowSelectors().length > 0}" } }
|
||||
%span
|
||||
+ {{ overFlowSelectors().length }} more
|
||||
%i.ofn-i_052-point-down
|
||||
.f-dropdown.text-right.content#show-more
|
||||
.f-dropdown.text-right.content{ ng: { attr: { id: "{{ 'show-more-' + selectorName }}" } } }
|
||||
%ul
|
||||
%active-selector{ ng: { repeat: "selector in overFlowSelectors()", hide: "selector.fits" } }
|
||||
%render-svg{path: "{{selector.object.icon}}"}
|
||||
%render-svg{path: "{{selector.object.icon}}", ng: { if: "selector.object.icon"}}
|
||||
%span {{ selector.object.name }}
|
||||
|
||||
Reference in New Issue
Block a user