workarea-classic_search_autocomplete 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. checksums.yaml +7 -0
  2. data/.editorconfig +20 -0
  3. data/.eslintrc +35 -0
  4. data/.eslintrc.json +35 -0
  5. data/.github/workflows/ci.yml +60 -0
  6. data/.gitignore +19 -0
  7. data/.rubocop.yml +2 -0
  8. data/.stylelintrc +8 -0
  9. data/.stylelintrc.json +8 -0
  10. data/CHANGELOG.md +19 -0
  11. data/Gemfile +17 -0
  12. data/LICENSE +52 -0
  13. data/README.md +45 -0
  14. data/Rakefile +60 -0
  15. data/app/assets/javascripts/jquery_ui/storefront/categorized_autocomplete.js +53 -0
  16. data/app/assets/javascripts/workarea/storefront/modules/search_fields.js +69 -0
  17. data/app/assets/javascripts/workarea/storefront/templates/ui_menu_heading.jst.ejs +1 -0
  18. data/app/assets/javascripts/workarea/storefront/templates/ui_menu_item.jst.ejs +8 -0
  19. data/app/assets/stylesheets/jquery_ui/storefront/_ui_autocomplete.scss +17 -0
  20. data/app/assets/stylesheets/jquery_ui/storefront/_ui_menu.scss +40 -0
  21. data/app/controllers/.keep +0 -0
  22. data/app/controllers/workarea/storefront/searches_controller.decorator +14 -0
  23. data/app/queries/workarea/search/search_suggestions.rb +45 -0
  24. data/app/view_models/workarea/storefront/search_suggestion_view_model.rb +85 -0
  25. data/app/views/workarea/storefront/searches/index.json.jbuilder +1 -0
  26. data/bin/rails +25 -0
  27. data/config/initializers/appends.rb +26 -0
  28. data/config/initializers/workarea.rb +2 -0
  29. data/config/routes.rb +5 -0
  30. data/lib/workarea/classic_search_autocomplete.rb +11 -0
  31. data/lib/workarea/classic_search_autocomplete/engine.rb +10 -0
  32. data/lib/workarea/classic_search_autocomplete/version.rb +5 -0
  33. data/package.json +9 -0
  34. data/script/admin_ci +9 -0
  35. data/script/ci +11 -0
  36. data/script/core_ci +9 -0
  37. data/script/plugins_ci +9 -0
  38. data/script/storefront_ci +9 -0
  39. data/test/dummy/.ruby-version +1 -0
  40. data/test/dummy/Rakefile +6 -0
  41. data/test/dummy/app/assets/config/manifest.js +3 -0
  42. data/test/dummy/app/assets/images/.keep +0 -0
  43. data/test/dummy/app/assets/javascripts/application.js +14 -0
  44. data/test/dummy/app/assets/stylesheets/application.css +15 -0
  45. data/test/dummy/app/controllers/application_controller.rb +2 -0
  46. data/test/dummy/app/controllers/concerns/.keep +0 -0
  47. data/test/dummy/app/helpers/application_helper.rb +2 -0
  48. data/test/dummy/app/jobs/application_job.rb +2 -0
  49. data/test/dummy/app/mailers/application_mailer.rb +4 -0
  50. data/test/dummy/app/models/concerns/.keep +0 -0
  51. data/test/dummy/app/views/layouts/application.html.erb +15 -0
  52. data/test/dummy/app/views/layouts/mailer.html.erb +13 -0
  53. data/test/dummy/app/views/layouts/mailer.text.erb +1 -0
  54. data/test/dummy/bin/bundle +3 -0
  55. data/test/dummy/bin/rails +4 -0
  56. data/test/dummy/bin/rake +4 -0
  57. data/test/dummy/bin/setup +25 -0
  58. data/test/dummy/bin/update +25 -0
  59. data/test/dummy/config.ru +5 -0
  60. data/test/dummy/config/application.rb +34 -0
  61. data/test/dummy/config/boot.rb +5 -0
  62. data/test/dummy/config/environment.rb +5 -0
  63. data/test/dummy/config/environments/development.rb +52 -0
  64. data/test/dummy/config/environments/production.rb +83 -0
  65. data/test/dummy/config/environments/test.rb +45 -0
  66. data/test/dummy/config/initializers/application_controller_renderer.rb +8 -0
  67. data/test/dummy/config/initializers/assets.rb +12 -0
  68. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  69. data/test/dummy/config/initializers/content_security_policy.rb +25 -0
  70. data/test/dummy/config/initializers/cookies_serializer.rb +5 -0
  71. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  72. data/test/dummy/config/initializers/inflections.rb +16 -0
  73. data/test/dummy/config/initializers/mime_types.rb +4 -0
  74. data/test/dummy/config/initializers/workarea.rb +5 -0
  75. data/test/dummy/config/initializers/wrap_parameters.rb +9 -0
  76. data/test/dummy/config/locales/en.yml +33 -0
  77. data/test/dummy/config/puma.rb +34 -0
  78. data/test/dummy/config/routes.rb +5 -0
  79. data/test/dummy/config/spring.rb +6 -0
  80. data/test/dummy/db/seeds.rb +2 -0
  81. data/test/dummy/lib/assets/.keep +0 -0
  82. data/test/dummy/log/.keep +0 -0
  83. data/test/integration/workarea/storefront/search_autocomplete_integration_test.rb +43 -0
  84. data/test/queries/workarea/search/search_suggestions_test.rb +77 -0
  85. data/test/system/workarea/storefront/search_autocomplete_analytics_system_test.rb +46 -0
  86. data/test/teaspoon_env.rb +6 -0
  87. data/test/test_helper.rb +10 -0
  88. data/test/view_models/workarea/storefront/search_suggestion_view_model_test.rb +42 -0
  89. data/workarea-classic_search_autocomplete.gemspec +25 -0
  90. data/yarn.lock +3265 -0
  91. metadata +156 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 9ed4771da702879caa17d04fa66eb40ac1681bb9e8517616553869bc4b6b5205
4
+ data.tar.gz: f57b6f73682db62db775e9ad13ac38a511d69ebf927ddcde3e272ab368e01eac
5
+ SHA512:
6
+ metadata.gz: 20089c6cc61f92c27fb51de35c9d7a0bbe481c1049ba591b5be1b15c74b8da39aa63e3e1c379bf1025e66915b1ccae7795660a75defeace47b63a0e7d0fd21ef
7
+ data.tar.gz: 5d8962f89a7c8619a5d79ba499bd0e38bde53ac773fcb2d5311521bbc5561118bd9191602b6a4d4553cd940d44306823ea6f1abc5e78db9cb65f16efcbb5bf66
data/.editorconfig ADDED
@@ -0,0 +1,20 @@
1
+ # editorconfig.org
2
+ root = true
3
+
4
+ [*]
5
+ charset = utf-8
6
+ indent_style = space
7
+ end_of_line = lf
8
+ trim_trailing_whitespace = true
9
+ insert_final_newline = true
10
+
11
+ [{*.rb,*.haml,*.decorator,*.yml,*.yaml,*.jbuilder}]
12
+ indent_size = 2
13
+ indent_style = space
14
+
15
+ [{*.js,*.jst,*.ejs,*.scss,*.js.erb}]
16
+ indent_size = 4
17
+
18
+ [*.md]
19
+ indent_size = 4
20
+ trim_trailing_whitespace = false
data/.eslintrc ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "extends": "eslint:recommended",
3
+ "rules": {
4
+ "semi": ["error", "always"],
5
+ "eqeqeq": ["error", "always"]
6
+ },
7
+ "globals": {
8
+ "window": true,
9
+ "document": true,
10
+ "WORKAREA": true,
11
+ "$": true,
12
+ "jQuery": true,
13
+ "_": true,
14
+ "feature": true,
15
+ "JST": true,
16
+ "Turbolinks": true,
17
+ "I18n": true,
18
+ "Chart": true,
19
+ "Dropzone": true,
20
+ "strftime": true,
21
+ "Waypoint": true,
22
+ "wysihtml": true,
23
+ "LocalTime": true,
24
+ "describe": true,
25
+ "after": true,
26
+ "afterEach": true,
27
+ "before": true,
28
+ "beforeEach": true,
29
+ "it": true,
30
+ "expect": true,
31
+ "sinon": true,
32
+ "fixture": true,
33
+ "chai": true
34
+ }
35
+ }
data/.eslintrc.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "extends": "eslint:recommended",
3
+ "rules": {
4
+ "semi": ["error", "always"],
5
+ "eqeqeq": ["error", "always"]
6
+ },
7
+ "globals": {
8
+ "window": true,
9
+ "document": true,
10
+ "WORKAREA": true,
11
+ "$": true,
12
+ "jQuery": true,
13
+ "_": true,
14
+ "feature": true,
15
+ "JST": true,
16
+ "Turbolinks": true,
17
+ "I18n": true,
18
+ "Chart": true,
19
+ "Dropzone": true,
20
+ "strftime": true,
21
+ "Waypoint": true,
22
+ "wysihtml": true,
23
+ "LocalTime": true,
24
+ "describe": true,
25
+ "after": true,
26
+ "afterEach": true,
27
+ "before": true,
28
+ "beforeEach": true,
29
+ "it": true,
30
+ "expect": true,
31
+ "sinon": true,
32
+ "fixture": true,
33
+ "chai": true
34
+ }
35
+ }
@@ -0,0 +1,60 @@
1
+ name: CI
2
+ on: [push]
3
+
4
+ jobs:
5
+ static_analysis:
6
+ runs-on: ubuntu-latest
7
+ steps:
8
+ - uses: actions/checkout@v1
9
+ - uses: workarea-commerce/ci/bundler-audit@v1
10
+ - uses: workarea-commerce/ci/rubocop@v1
11
+ - uses: workarea-commerce/ci/eslint@v1
12
+ with:
13
+ args: '**/*.js'
14
+ - uses: workarea-commerce/ci/stylelint@v1
15
+ with:
16
+ args: '**/*.scss'
17
+
18
+ admin_tests:
19
+ runs-on: ubuntu-latest
20
+ steps:
21
+ - uses: actions/checkout@v1
22
+ - uses: actions/setup-ruby@v1
23
+ with:
24
+ ruby-version: 2.6.x
25
+ - uses: workarea-commerce/ci/test@v1
26
+ with:
27
+ command: bin/rails app:workarea:test:admin
28
+
29
+ core_tests:
30
+ runs-on: ubuntu-latest
31
+ steps:
32
+ - uses: actions/checkout@v1
33
+ - uses: actions/setup-ruby@v1
34
+ with:
35
+ ruby-version: 2.6.x
36
+ - uses: workarea-commerce/ci/test@v1
37
+ with:
38
+ command: bin/rails app:workarea:test:core
39
+
40
+ storefront_tests:
41
+ runs-on: ubuntu-latest
42
+ steps:
43
+ - uses: actions/checkout@v1
44
+ - uses: actions/setup-ruby@v1
45
+ with:
46
+ ruby-version: 2.6.x
47
+ - uses: workarea-commerce/ci/test@v1
48
+ with:
49
+ command: bin/rails app:workarea:test:storefront
50
+
51
+ plugins_tests:
52
+ runs-on: ubuntu-latest
53
+ steps:
54
+ - uses: actions/checkout@v1
55
+ - uses: actions/setup-ruby@v1
56
+ with:
57
+ ruby-version: 2.6.x
58
+ - uses: workarea-commerce/ci/test@v1
59
+ with:
60
+ command: bin/rails app:workarea:test:plugins
data/.gitignore ADDED
@@ -0,0 +1,19 @@
1
+ .bundle/
2
+ log/*.log
3
+ pkg/
4
+ test/dummy/log/*.log
5
+ test/dummy/tmp/
6
+ .DS_Store
7
+ .byebug_history
8
+ .bundle/
9
+ .sass-cache/
10
+ Gemfile.lock
11
+ pkg/
12
+ test/dummy/tmp/
13
+ test/dummy/public/
14
+ log/*.log
15
+ test/dummy/log/*.log
16
+ test/dummy/db/*.sqlite3
17
+ test/dummy/db/*.sqlite3-journal
18
+ node_modules
19
+ .rubocop-http*
data/.rubocop.yml ADDED
@@ -0,0 +1,2 @@
1
+ inherit_from:
2
+ - https://raw.githubusercontent.com/workarea-commerce/workarea/master/.rubocop.yml
data/.stylelintrc ADDED
@@ -0,0 +1,8 @@
1
+ {
2
+ "extends": "stylelint-config-recommended-scss",
3
+ "rules": {
4
+ "block-no-empty": null,
5
+ "no-descending-specificity": null,
6
+ "property-no-unknown": [true, { "ignoreProperties": ["mso-hide"] }]
7
+ }
8
+ }
data/.stylelintrc.json ADDED
@@ -0,0 +1,8 @@
1
+ {
2
+ "extends": "stylelint-config-recommended-scss",
3
+ "rules": {
4
+ "block-no-empty": null,
5
+ "no-descending-specificity": null,
6
+ "property-no-unknown": [true, { "ignoreProperties": ["mso-hide"] }]
7
+ }
8
+ }
data/CHANGELOG.md ADDED
@@ -0,0 +1,19 @@
1
+ Workarea Classic Search Autocomplete 1.0.0 (2019-11-26)
2
+ --------------------------------------------------------------------------------
3
+
4
+ * Update SearchSuggestions query to fix build
5
+
6
+ Matt Duffy
7
+
8
+ * Add Classic Search Autocomplete functionality
9
+
10
+ The word "classic" in the subject refers to something that is antique
11
+ and nostalgic but still in working condition.
12
+
13
+ For a better, albeit more designed and opinionated solution, set your
14
+ peepers on
15
+ https://github.com/workarea-commerce/workarea-search-autocomplete
16
+ Curt Howard
17
+
18
+
19
+
data/Gemfile ADDED
@@ -0,0 +1,17 @@
1
+ source 'https://rubygems.org'
2
+ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
3
+
4
+ # Declare your gem's dependencies in classic_search_autocomplete.gemspec.
5
+ # Bundler will treat runtime dependencies like base dependencies, and
6
+ # development dependencies will be added by default to the :development group.
7
+ gemspec
8
+
9
+ # Declare any dependencies that are still in development here instead of in
10
+ # your gemspec. These might include edge Rails or gems from your path or
11
+ # Git. Remember to move these dependencies to your gemspec before releasing
12
+ # your gem to rubygems.org.
13
+
14
+ # To use a debugger
15
+ # gem 'byebug', group: [:development, :test]
16
+
17
+ gem 'workarea', github: 'workarea-commerce/workarea'
data/LICENSE ADDED
@@ -0,0 +1,52 @@
1
+ WebLinc
2
+ Business Source License
3
+
4
+ Licensor: WebLinc Corporation, 22 S. 3rd Street, 2nd Floor, Philadelphia PA 19106
5
+
6
+ Licensed Work: Workarea Commerce Platform
7
+ The Licensed Work is (c) 2019 WebLinc Corporation
8
+
9
+ Additional Use Grant:
10
+ You may make production use of the Licensed Work without an additional license agreement with WebLinc so long as you do not use the Licensed Work for a Commerce Service.
11
+
12
+ A "Commerce Service" is a commercial offering that allows third parties (other than your employees and contractors) to access the functionality of the Licensed Work by creating or managing commerce functionality, the products, taxonomy, assets and/or content of which are controlled by such third parties.
13
+
14
+ For information about obtaining an additional license agreement with WebLinc, contact licensing@workarea.com.
15
+
16
+ Change Date: 2019-08-20
17
+
18
+ Change License: Version 2.0 or later of the GNU General Public License as published by the Free Software Foundation
19
+
20
+ Terms
21
+
22
+ The Licensor hereby grants you the right to copy, modify, create derivative works, redistribute, and make non-production use of the Licensed Work. The Licensor may make an Additional Use Grant, above, permitting limited production use.
23
+
24
+ Effective on the Change Date, or the fourth anniversary of the first publicly available distribution of a specific version of the Licensed Work under this License, whichever comes first, the Licensor hereby grants you rights under the terms of the Change License, and the rights granted in the paragraph above terminate.
25
+
26
+ If your use of the Licensed Work does not comply with the requirements currently in effect as described in this License, you must purchase a commercial license from the Licensor, its affiliated entities, or authorized resellers, or you must refrain from using the Licensed Work.
27
+
28
+ All copies of the original and modified Licensed Work, and derivative works of the Licensed Work, are subject to this License. This License applies separately for each version of the Licensed Work and the Change Date may vary for each version of the Licensed Work released by Licensor.
29
+
30
+ You must conspicuously display this License on each original or modified copy of the Licensed Work. If you receive the Licensed Work in original or modified form from a third party, the terms and conditions set forth in this License apply to your use of that work.
31
+
32
+ Any use of the Licensed Work in violation of this License will automatically terminate your rights under this License for the current and all other versions of the Licensed Work.
33
+
34
+ This License does not grant you any right in any trademark or logo of Licensor or its affiliates (provided that you may use a trademark or logo of Licensor as expressly required by this License). TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS, EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND TITLE. MariaDB hereby grants you permission to use this License’s text to license your works and to refer to it using the trademark "Business Source License" as long as you comply with the Covenants of Licensor below.
35
+
36
+ Covenants of Licensor
37
+ In consideration of the right to use this License’s text and the "Business Source License" name and trademark, Licensor covenants to MariaDB, and to all other recipients of the licensed work to be provided by Licensor:
38
+
39
+ To specify as the Change License the GPL Version 2.0 or any later version, or a license that is compatible with GPL Version 2.0 or a later version, where "compatible" means that software provided under the Change License can be included in a program with software provided under GPL Version 2.0 or a later version. Licensor may specify additional Change Licenses without limitation.
40
+
41
+ To either: (a) specify an additional grant of rights to use that does not impose any additional restriction on the right granted in this License, as the Additional Use Grant; or (b) insert the text "None."
42
+
43
+ To specify a Change Date.
44
+
45
+ Not to modify this License in any other way.
46
+
47
+ Notice
48
+ The Business Source License (this document, or the "License") is not an Open Source license. However, the Licensed Work will eventually be made available under an Open Source License, as stated in this License.
49
+
50
+ For more information on the use of the Business Source License generally, please visit the Adopting and Developing Business Source License FAQ.
51
+
52
+ License text copyright (c) 2017 MariaDB Corporation Ab, All Rights Reserved. "Business Source License" is a trademark of MariaDB Corporation Ab.
data/README.md ADDED
@@ -0,0 +1,45 @@
1
+ # Workarea Classic Search Autocomplete
2
+
3
+ A Workarea Commerce plugin providing a simple Search Autocomplete UI
4
+
5
+ This feature has been pluginized directly from Workarea v3.4 and subsequently removed in Workarea v3.5.
6
+
7
+ If you are __upgrading from Workarea v3.4 to Workarea v3.5__ it is likely you'll want to install this plugin to ensure the expedience and consistency of your upgrade.
8
+
9
+ It should be noted that [workarea-commerce/workarea-search-autocomplete](https://github.com/workarea-commerce/workarea-search-autocomplete) exists and provides a better UX and UI for customers.
10
+
11
+ # Overview
12
+
13
+ * Find-as-you-type functionality
14
+ * Produces a list of products, containing small thumbnail & name
15
+
16
+ # Getting Started
17
+
18
+ Add the gem to your application's Gemfile:
19
+
20
+ ```ruby
21
+ # ...
22
+ gem 'workarea-classic_search_autocomplete'
23
+ # ...
24
+ ```
25
+
26
+ Update your application's bundle.
27
+
28
+ ```bash
29
+ cd path/to/application
30
+ bundle
31
+ ```
32
+
33
+ # Features
34
+
35
+ ## jQuery UI Autocomplete
36
+
37
+ This plugin utilizes the jQuery UI Autocomplete widget to keyboard and ARIA accessibility best practices.
38
+
39
+ # Workarea Platform Documentation
40
+
41
+ See [http://developer.workarea.com](http://developer.workarea.com) for Workarea platform documentation.
42
+
43
+ # License
44
+
45
+ Workarea Classic Search Autocomplete is released under the [Business Software License](LICENSE)
data/Rakefile ADDED
@@ -0,0 +1,60 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+ RDoc::Task.new(:rdoc) do |rdoc|
9
+ rdoc.rdoc_dir = 'rdoc'
10
+ rdoc.title = 'Classic Search Autocomplete'
11
+ rdoc.options << '--line-numbers'
12
+ rdoc.rdoc_files.include('README.md')
13
+ rdoc.rdoc_files.include('lib/**/*.rb')
14
+ end
15
+
16
+ APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
17
+ load 'rails/tasks/engine.rake'
18
+ load 'rails/tasks/statistics.rake'
19
+ load 'workarea/changelog.rake'
20
+
21
+ require 'rake/testtask'
22
+ Rake::TestTask.new(:test) do |t|
23
+ t.libs << 'lib'
24
+ t.libs << 'test'
25
+ t.pattern = 'test/**/*_test.rb'
26
+ t.verbose = false
27
+ end
28
+ task default: :test
29
+
30
+ $LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
31
+ require 'workarea/classic_search_autocomplete/version'
32
+
33
+ desc "Release version #{Workarea::ClassicSearchAutocomplete::VERSION} of the gem"
34
+ task :release do
35
+ host = "https://#{ENV['BUNDLE_GEMS__WEBLINC__COM']}@gems.weblinc.com"
36
+
37
+ Rake::Task['workarea:changelog'].execute
38
+ system 'git add CHANGELOG.md'
39
+ system 'git commit -m "Update CHANGELOG"'
40
+ system 'git push origin HEAD'
41
+
42
+ system "git tag -a v#{Workarea::ClassicSearchAutocomplete::VERSION} -m 'Tagging #{Workarea::ClassicSearchAutocomplete::VERSION}'"
43
+ system 'git push --tags'
44
+
45
+ system "gem build workarea-classic_search_autocomplete.gemspec"
46
+ system "gem push workarea-classic_search_autocomplete-#{Workarea::ClassicSearchAutocomplete::VERSION}.gem"
47
+ system "gem push workarea-classic_search_autocomplete-#{Workarea::ClassicSearchAutocomplete::VERSION}.gem --host #{host}"
48
+ system "rm workarea-classic_search_autocomplete-#{Workarea::ClassicSearchAutocomplete::VERSION}.gem"
49
+ end
50
+
51
+ desc 'Run the JavaScript tests'
52
+ ENV['TEASPOON_RAILS_ENV'] = File.expand_path('../test/dummy/config/environment', __FILE__)
53
+ task teaspoon: 'app:teaspoon'
54
+
55
+ desc 'Start a server at http://localhost:3000/teaspoon for JavaScript tests'
56
+ task :teaspoon_server do
57
+ Dir.chdir("test/dummy")
58
+ teaspoon_env = File.expand_path('../test/teaspoon_env.rb', __FILE__)
59
+ system "RAILS_ENV=test TEASPOON_ENV=#{teaspoon_env} rails s"
60
+ end
@@ -0,0 +1,53 @@
1
+ /**
2
+ * @external jQuery
3
+ */
4
+
5
+ /**
6
+ * @method
7
+ * @name categorizedAutocomplete
8
+ * @memberof external:jQuery
9
+ */
10
+ $.widget('workarea.categorizedAutocomplete', $.ui.autocomplete, {
11
+ _create: function () {
12
+ 'use strict';
13
+
14
+ this._super();
15
+
16
+ this.widget().menu(
17
+ 'option', 'items', '> :not(.ui-menu-heading)'
18
+ );
19
+ },
20
+
21
+ _renderItem: function ($ul, item) {
22
+ 'use strict';
23
+
24
+ var itemTemplate = JST['workarea/storefront/templates/ui_menu_item'];
25
+
26
+ return $(itemTemplate({ label: item.label, image: item.image })).appendTo($ul);
27
+ },
28
+
29
+ _renderMenu: function ($ul, items) {
30
+ 'use strict';
31
+
32
+ var widget = this,
33
+ categories = _.uniq(_.map(items, 'type')),
34
+ itemsByCategory = _.groupBy(items, 'type'),
35
+ categoryHeaderTemplate = JST['workarea/storefront/templates/ui_menu_heading'],
36
+
37
+ renderCategoryItem = function (item) {
38
+ widget._renderItemData($ul, item);
39
+ },
40
+
41
+ renderCategory = function (category) {
42
+ $ul.append(categoryHeaderTemplate({
43
+ categoryName: category
44
+ }));
45
+
46
+ _.forEach(
47
+ itemsByCategory[category], renderCategoryItem
48
+ );
49
+ };
50
+
51
+ _.forEach(categories, renderCategory);
52
+ }
53
+ });