mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-15 23:57:48 +00:00
Add viewing_as_coordiantor flag to serialized order cycles and a managed flag to serialized enterprises for_order_cycle(s)
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
class Api::Admin::OrderCycleSerializer < ActiveModel::Serializer
|
||||
attributes :id, :name, :orders_open_at, :orders_close_at, :coordinator_id, :exchanges
|
||||
attributes :viewing_as_coordinator
|
||||
attributes :editable_variants_for_incoming_exchanges, :editable_variants_for_outgoing_exchanges
|
||||
attributes :visible_variants_for_outgoing_exchanges
|
||||
|
||||
@@ -13,6 +14,10 @@ class Api::Admin::OrderCycleSerializer < ActiveModel::Serializer
|
||||
object.orders_close_at.to_s
|
||||
end
|
||||
|
||||
def viewing_as_coordinator
|
||||
Enterprise.managed_by(options[:current_user]).include? object.coordinator
|
||||
end
|
||||
|
||||
def exchanges
|
||||
scoped_exchanges = OpenFoodNetwork::Permissions.new(options[:current_user]).order_cycle_exchanges(object).order('id ASC')
|
||||
ActiveModel::ArraySerializer.new(scoped_exchanges, {each_serializer: Api::Admin::ExchangeSerializer, current_user: options[:current_user] })
|
||||
|
||||
@@ -2,6 +2,8 @@ collection @collection
|
||||
|
||||
attributes :id, :name
|
||||
|
||||
node(:managed) { |enterprise| Enterprise.managed_by(spree_current_user).include? enterprise }
|
||||
|
||||
node(:supplied_products) do |enterprise|
|
||||
enterprise.supplied_products.not_deleted.map do |product|
|
||||
partial 'admin/enterprises/supplied_product', object: product
|
||||
|
||||
@@ -9,9 +9,9 @@
|
||||
selected
|
||||
- if type == 'distributor'
|
||||
%td.collection-details
|
||||
= text_field_tag 'order_cycle_outgoing_exchange_{{ $index }}_pickup_time', '', 'id' => 'order_cycle_outgoing_exchange_{{ $index }}_pickup_time', 'placeholder' => 'Ready for (ie. Date / Time)', 'ng-model' => 'exchange.pickup_time'
|
||||
= text_field_tag 'order_cycle_outgoing_exchange_{{ $index }}_pickup_time', '', 'id' => 'order_cycle_outgoing_exchange_{{ $index }}_pickup_time', 'placeholder' => 'Ready for (ie. Date / Time)', 'ng-model' => 'exchange.pickup_time', 'ng-disabled' => '!enterprises[exchange.enterprise_id].managed && !order_cycle.viewing_as_coordinator'
|
||||
%br/
|
||||
= text_field_tag 'order_cycle_outgoing_exchange_{{ $index }}_pickup_instructions', '', 'id' => 'order_cycle_outgoing_exchange_{{ $index }}_pickup_instructions', 'placeholder' => 'Pick-up instructions', 'ng-model' => 'exchange.pickup_instructions'
|
||||
= text_field_tag 'order_cycle_outgoing_exchange_{{ $index }}_pickup_instructions', '', 'id' => 'order_cycle_outgoing_exchange_{{ $index }}_pickup_instructions', 'placeholder' => 'Pick-up instructions', 'ng-model' => 'exchange.pickup_instructions', 'ng-disabled' => '!enterprises[exchange.enterprise_id].managed && !order_cycle.viewing_as_coordinator'
|
||||
%td.fees
|
||||
%ol
|
||||
%li{'ng-repeat' => 'enterprise_fee in exchange.enterprise_fees'}
|
||||
|
||||
Reference in New Issue
Block a user