-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #79 from friendlycart/promotions-index-improvements
Promotions index improvements
- Loading branch information
Showing
9 changed files
with
161 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
promotions/app/views/solidus_friendly_promotions/admin/promotions/_table.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<table class="index"> | ||
<thead> | ||
<tr> | ||
<th><%= sort_link @search, :name %></th> | ||
<th><%= SolidusFriendlyPromotions::Promotion.human_attribute_name(:code) %></th> | ||
<th><%= SolidusFriendlyPromotions::Promotion.human_attribute_name(:status) %></th> | ||
<th><%= SolidusFriendlyPromotions::Promotion.human_attribute_name(:usage) %></th> | ||
<th><%= sort_link @search, :starts_at %></th> | ||
<th><%= sort_link @search, :expires_at %></th> | ||
<th><%= SolidusFriendlyPromotions::Promotion.human_attribute_name(:lane) %></th> | ||
<th><%= sort_link @search, :updated_at %></th> | ||
<th class="actions"></th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<% promotions.each do |promotion| %> | ||
<tr id="<%= spree_dom_id promotion %>"> | ||
<td><%= promotion.name %></td> | ||
<td> | ||
<%= (promotion.codes.size == 1) ? promotion.codes.pluck(:value).first : t('solidus_friendly_promotions.number_of_codes', count: promotion.codes.size) %> | ||
</td> | ||
<td> | ||
<span class="pill pill-<%= promotion.active? ? 'active' : 'inactive' %>"> | ||
<%= t(admin_promotion_status(promotion), scope: 'solidus_friendly_promotions.admin.promotion_status') %> | ||
</span> | ||
</td> | ||
<td> | ||
<% if promotion.usage_limit.nil? %> | ||
<%= promotion.discounted_orders.exists? ? t(:say_yes, scope: :spree) : t(:say_no, scope: :spree) %> | ||
<% else %> | ||
<%= promotion.usage_count %> / <%= promotion.usage_limit %> | ||
<% end %> | ||
<td> | ||
<%= l(promotion.starts_at, format: :short) if promotion.starts_at %> | ||
</td> | ||
<td> | ||
<%= l(promotion.expires_at, format: :short) if promotion.expires_at %> | ||
</td> | ||
<td> | ||
<%= SolidusFriendlyPromotions::Promotion.human_enum_name(:lane, promotion.lane) %> | ||
</td> | ||
<td> | ||
<%= l(promotion.updated_at, format: :short) %> | ||
</td> | ||
<td class="actions"> | ||
<% if can?(:edit, promotion) %> | ||
<%= link_to_edit promotion, no_text: true %> | ||
<% end %> | ||
<% if can?(:destroy, promotion) %> | ||
<%= link_to_delete promotion, no_text: true %> | ||
<% end %> | ||
</td> | ||
</tr> | ||
<% end %> | ||
</tbody> | ||
</table> |
69 changes: 69 additions & 0 deletions
69
promotions/app/views/solidus_friendly_promotions/admin/promotions/_table_filter.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<% content_for :table_filter_title do %> | ||
<%= t('spree.search') %> | ||
<% end %> | ||
|
||
<% content_for :table_filter do %> | ||
<div data-hook="admin_promotions_index_search"> | ||
<%= search_form_for [:admin, search] do |f| %> | ||
<div class="row"> | ||
<div class="col-4"> | ||
<div class="field"> | ||
<%= label_tag :q_name_cont, SolidusFriendlyPromotions::Promotion.human_attribute_name(:name) %> | ||
<%= f.text_field :name_cont, tabindex: 1 %> | ||
</div> | ||
</div> | ||
|
||
<div class="col-4"> | ||
<div class="field"> | ||
<%= label_tag :q_customer_label_cont, SolidusFriendlyPromotions::Promotion.human_attribute_name(:customer_label) %> | ||
<%= f.text_field :customer_label_cont, tabindex: 1 %> | ||
</div> | ||
</div> | ||
|
||
<div class="col-2"> | ||
<div class="field"> | ||
<%= label_tag :q_codes_value_cont, SolidusFriendlyPromotions::Promotion.human_attribute_name(:code) %> | ||
<%= f.text_field :codes_value_cont, tabindex: 1 %> | ||
</div> | ||
</div> | ||
|
||
<div class="col-2"> | ||
<div class="field"> | ||
<%= label_tag :q_path_cont, SolidusFriendlyPromotions::Promotion.human_attribute_name(:path) %> | ||
<%= f.text_field :path_cont, tabindex: 1 %> | ||
</div> | ||
</div> | ||
|
||
<div class="col-2"> | ||
<div class="date-range-filter field"> | ||
<%= label_tag :q_active, SolidusFriendlyPromotions::Promotion.human_attribute_name(:active) %> | ||
<%= f.text_field :active, value: params[:q][:active], | ||
class: 'datepicker datepicker-from fullwidth', | ||
data: { :'enable-time' => true, :'default-hour' => 0 } %> | ||
</div> | ||
</div> | ||
|
||
<div class="col-2"> | ||
<div class="field"> | ||
<%= label_tag :q_promotion_category_id_eq, SolidusFriendlyPromotions::PromotionCategory.model_name.human %><br> | ||
<%= f.collection_select(:promotion_category_id_eq, @promotion_categories, :id, :name, { include_blank: t(:all, scope: :spree) }, { class: 'custom-select fullwidth' }) %> | ||
</div> | ||
</div> | ||
|
||
<div class="col-2"> | ||
<div class="field"> | ||
<%= label_tag :q_lane_eq, SolidusFriendlyPromotions::Promotion.human_attribute_name(:lane) %><br> | ||
<%= f.select(:lane_eq, SolidusFriendlyPromotions::Promotion.lane_options, { include_blank: t(:all, scope: :spree) }, { class: 'custom-select fullwidth' }) %> | ||
</div> | ||
</div> | ||
|
||
</div> | ||
|
||
<div class="actions filter-actions"> | ||
<div data-hook="admin_promotions_index_search_buttons"> | ||
<%= button_tag t('spree.filter_results'), class: 'btn btn-primary' %> | ||
</div> | ||
</div> | ||
<% end %> | ||
</div> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters