-
-
Notifications
You must be signed in to change notification settings - Fork 725
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master' into openstreetmap-tiles
- Loading branch information
Showing
19 changed files
with
159 additions
and
18 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
9 changes: 9 additions & 0 deletions
9
app/assets/javascripts/admin/customers/services/tags_resource.js.coffee
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,9 @@ | ||
angular.module("admin.customers").factory 'TagsResource', ($resource) -> | ||
$resource('/admin/tags.json', {}, { | ||
'index': | ||
method: 'GET' | ||
isArray: true | ||
cache: true | ||
params: | ||
enterprise_id: '@enterprise_id' | ||
}) |
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
app/assets/javascripts/admin/shipping_methods/shipping_methods.js.coffee
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 |
---|---|---|
@@ -1 +1 @@ | ||
angular.module("admin.shippingMethods", ["ngTagsInput", 'admin.utils']) | ||
angular.module("admin.shippingMethods", ["ngTagsInput", 'admin.utils', 'templates']) |
3 changes: 2 additions & 1 deletion
3
app/assets/javascripts/admin/utils/directives/tags_with_translation.js.coffee
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
7 changes: 7 additions & 0 deletions
7
app/assets/javascripts/admin/utils/filters/translate.js.coffee
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,7 @@ | ||
angular.module("admin.utils").filter "translate", -> | ||
(key, options) -> | ||
t(key, options) | ||
|
||
angular.module("admin.utils").filter "t", -> | ||
(key, options) -> | ||
t(key, options) |
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,8 @@ | ||
.tag-template | ||
%div | ||
%span.tag-with-rules{ ng: { if: "data.rules" }, "ofn-with-tip" => "{{ 'admin.tag_has_rules' | t:{num: data.rules} }}" } | ||
{{$getDisplayText()}} | ||
%span{ ng: { if: "!data.rules" } } | ||
{{$getDisplayText()}} | ||
%a.remove-button{ ng: {click: "$removeTag()"} } | ||
✖ |
11 changes: 11 additions & 0 deletions
11
app/assets/javascripts/templates/admin/tag_autocomplete.html.haml
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,11 @@ | ||
.autocomplete-template | ||
%span.tag-with-rules{ ng: { if: "data.rules" } } | ||
{{$getDisplayText()}} | ||
%span.tag-with-rules{ ng: { if: "data.rules == 1" } } | ||
— | ||
= t 'admin.has_one_rule' | ||
%span.tag-with-rules{ ng: { if: "data.rules > 1" } } | ||
— | ||
= t 'admin.has_n_rules', { num: '{{data.rules}}' } | ||
%span{ ng: { if: "!data.rules" } } | ||
{{$getDisplayText()}} |
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,7 @@ | ||
%tags-input{ template: 'admin/tag.html', ng: { model: 'object[tagsAttr]' } } | ||
%auto-complete{source: "findTags({query: $query})", | ||
template: "admin/tag_autocomplete.html", | ||
"min-length" => "0", | ||
"load-on-focus" => "true", | ||
"load-on-empty" => "true", | ||
"max-results-to-show" => "32"} |
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,3 @@ | ||
.tag-with-rules { | ||
color: black; | ||
} |
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,28 @@ | ||
module Admin | ||
class TagsController < Spree::Admin::BaseController | ||
respond_to :json | ||
|
||
def index | ||
respond_to do |format| | ||
format.json do | ||
serialiser = ActiveModel::ArraySerializer.new(tags_of_enterprise) | ||
render json: serialiser.to_json | ||
end | ||
end | ||
end | ||
|
||
private | ||
|
||
def enterprise | ||
Enterprise.managed_by(spree_current_user).find_by_id(params[:enterprise_id]) | ||
end | ||
|
||
def tags_of_enterprise | ||
return [] unless enterprise | ||
tag_rule_map = enterprise.rules_per_tag | ||
tag_rule_map.keys.map do |tag| | ||
{ text: tag, rules: tag_rule_map[tag] } | ||
end | ||
end | ||
end | ||
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
describe Api::Admin::CustomerSerializer do | ||
let(:customer) { create(:customer, tag_list: "one, two, three") } | ||
let!(:tag_rule) { create(:tag_rule, enterprise: customer.enterprise, preferred_customer_tags: "two") } | ||
|
||
it "serializes a customer" do | ||
serializer = Api::Admin::CustomerSerializer.new customer | ||
result = JSON.parse(serializer.to_json) | ||
expect(result['email']).to eq customer.email | ||
tags = result['tags'] | ||
expect(tags.length).to eq 3 | ||
expect(tags[0]).to eq({ "text" => 'one', "rules" => nil }) | ||
expect(tags[1]).to eq({ "text" => 'two', "rules" => 1 }) | ||
end | ||
end |