Files
openfoodnetwork/app/views/admin/enterprises/form/_users.html.haml
2018-02-07 10:41:52 +11:00

64 lines
2.2 KiB
Plaintext

- owner_email = @enterprise.andand.owner.andand.email || ""
- full_permissions = (spree_current_user.admin? || spree_current_user == @enterprise.andand.owner)
.row
.three.columns.alpha
=f.label :owner_id, t('.owner')
- if full_permissions
%span.required *
%div{'ofn-with-tip' => t('.owner_tip')}
%a= t('admin.whats_this')
.eight.columns.omega
- if full_permissions
= f.hidden_field :owner_id, class: "select2 fullwidth", 'user-select' => 'Enterprise.owner'
- else
= owner_email
-# TODO: add contact field, possibly re-use some of these tooltip keys
-#.row
-# .three.columns.alpha
-# = f.label :email, t('.notifications')
-# - if full_permissions
-# %span.required *
-# .with-tip{'data-powertip' => t('.notifications_tip')}
-# %a= t('admin.whats_this')
-# .eight.columns.omega
-# - if full_permissions
-# = f.text_field :email, { placeholder: t('.notifications_placeholder'), "ng-model" => "Enterprise.email" }
-# - else
-# = @enterprise.email
-#.row{ ng: { hide: "pristineEmail == null || pristineEmail == Enterprise.email"} }
-# .alpha.three.columns
-#  
-# .omega.eight.columns
-# = t('.notifications_note')
.row
.three.columns.alpha
=f.label :user_ids, t('.managers')
- if full_permissions
%span.required *
%div{'ofn-with-tip' => t('.managers_tip')}
%a= t('admin.whats_this')
.eight.columns.omega
- if full_permissions
%table
%tr
%td
- # Ignore this input in the submit
= hidden_field_tag :ignored, :new_manager, class: "select2 fullwidth", 'user-select' => 'newManager', 'ng-model' => 'newManager'
%td.actions
%a{ 'ng-click' => 'addManager(newManager)', :class => "icon-plus no-text" }
%tr.animate-repeat{ ng: { repeat: 'manager in Enterprise.users' }}
%td
= hidden_field_tag "enterprise[user_ids][]", nil, multiple: true, 'ng-value' => 'manager.id'
{{ manager.email }}
%td.actions
%a{ ng: {click: 'removeManager(manager)', class: "{disabled: manager.id == Enterprise.owner.id}"}, :class => "icon-trash no-text" }
- else
- @enterprise.users.each do |manager|
= manager.email
%br