workarea-registries 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/Gemfile +9 -0
- data/LICENSE +21 -0
- data/README.md +1 -0
- data/Rakefile +58 -0
- data/app/assets/images/workarea/storefront/registries/icons/email.svg +4 -0
- data/app/assets/images/workarea/storefront/registries/icons/link.svg +1 -0
- data/app/assets/javascripts/workarea/storefront/registries/modules/add_to_registry_button.js +49 -0
- data/app/assets/javascripts/workarea/storefront/registries/modules/copy_registry_url_button.js +51 -0
- data/app/assets/javascripts/workarea/storefront/registries/modules/toggle_registry_address.js +58 -0
- data/app/assets/javascripts/workarea/storefront/registries/templates/add_to_registry_button.jst.ejs +3 -0
- data/app/controllers/workarea/admin/registries_controller.rb +28 -0
- data/app/controllers/workarea/storefront/cart_items_controller.decorator +14 -0
- data/app/controllers/workarea/storefront/registries_controller.rb +47 -0
- data/app/controllers/workarea/storefront/users/registries_controller.rb +94 -0
- data/app/controllers/workarea/storefront/users/registry_items_controller.rb +67 -0
- data/app/controllers/workarea/storefront/users/registry_shares_controller.rb +43 -0
- data/app/controllers/workarea/storefront/users/registry_thanks_controller.rb +41 -0
- data/app/helpers/workarea/registries_helper.rb +41 -0
- data/app/mailers/workarea/storefront/registries_mailer.rb +52 -0
- data/app/models/workarea/checkout/steps/addresses.decorator +28 -0
- data/app/models/workarea/order.decorator +7 -0
- data/app/models/workarea/order/item.decorator +11 -0
- data/app/models/workarea/registry.rb +129 -0
- data/app/models/workarea/registry/item.rb +39 -0
- data/app/models/workarea/registry/public_search.rb +23 -0
- data/app/models/workarea/registry/share.rb +46 -0
- data/app/models/workarea/registry/thank.rb +26 -0
- data/app/models/workarea/search/admin/registry.rb +29 -0
- data/app/queries/workarea/search/admin_orders.decorator +7 -0
- data/app/queries/workarea/search/admin_registries.rb +16 -0
- data/app/seeds/workarea/registry_content_seeds.rb +50 -0
- data/app/services/workarea/inventory_adjustment.decorator +43 -0
- data/app/view_models/workarea/admin/registry_view_model.rb +19 -0
- data/app/view_models/workarea/storefront/checkout/addresses_view_model.decorator +17 -0
- data/app/view_models/workarea/storefront/order_item_view_model.decorator +9 -0
- data/app/view_models/workarea/storefront/order_view_model.decorator +8 -0
- data/app/view_models/workarea/storefront/registry_email_view_model.rb +37 -0
- data/app/view_models/workarea/storefront/registry_item_view_model.rb +72 -0
- data/app/view_models/workarea/storefront/registry_share_view_model.rb +6 -0
- data/app/view_models/workarea/storefront/registry_thank_view_model.rb +6 -0
- data/app/view_models/workarea/storefront/registry_view_model.rb +74 -0
- data/app/view_models/workarea/storefront/user_view_model.decorator +12 -0
- data/app/views/workarea/admin/registries/_menu.html.haml +1 -0
- data/app/views/workarea/admin/registries/index.html.haml +70 -0
- data/app/views/workarea/storefront/carts/_registry_details.html.haml +3 -0
- data/app/views/workarea/storefront/checkouts/_registry_address.html.haml +13 -0
- data/app/views/workarea/storefront/checkouts/_registry_address_fields.html.haml +28 -0
- data/app/views/workarea/storefront/checkouts/_registry_details.html.haml +3 -0
- data/app/views/workarea/storefront/products/_add_to_registry_placeholder.html.haml +1 -0
- data/app/views/workarea/storefront/registries/_registries_link.html.haml +4 -0
- data/app/views/workarea/storefront/registries/index.html.haml +39 -0
- data/app/views/workarea/storefront/registries/search.html.haml +35 -0
- data/app/views/workarea/storefront/registries/show.html.haml +63 -0
- data/app/views/workarea/storefront/registries_mailer/creation.html.haml +13 -0
- data/app/views/workarea/storefront/registries_mailer/gift_receipt.html.haml +51 -0
- data/app/views/workarea/storefront/registries_mailer/share.html.haml +21 -0
- data/app/views/workarea/storefront/registries_mailer/thank.html.haml +19 -0
- data/app/views/workarea/storefront/users/_registry_count.json.jbuilder +3 -0
- data/app/views/workarea/storefront/users/accounts/_registries.html.haml +14 -0
- data/app/views/workarea/storefront/users/registries/_form.html.haml +56 -0
- data/app/views/workarea/storefront/users/registries/_radio_list.html.haml +8 -0
- data/app/views/workarea/storefront/users/registries/_summary.html.haml +12 -0
- data/app/views/workarea/storefront/users/registries/edit.html.haml +4 -0
- data/app/views/workarea/storefront/users/registries/index.html.haml +24 -0
- data/app/views/workarea/storefront/users/registries/new.html.haml +4 -0
- data/app/views/workarea/storefront/users/registries/show.html.haml +75 -0
- data/app/views/workarea/storefront/users/registry_items/new.html.haml +10 -0
- data/app/views/workarea/storefront/users/registry_items/templates/_purchased.html.haml +29 -0
- data/app/views/workarea/storefront/users/registry_items/templates/_unpurchased.html.haml +35 -0
- data/app/views/workarea/storefront/users/registry_shares/_share_buttons.html.haml +18 -0
- data/app/views/workarea/storefront/users/registry_shares/new.html.haml +49 -0
- data/app/views/workarea/storefront/users/registry_thanks/new.html.haml +47 -0
- data/app/workers/workarea/send_gift_receipt.rb +15 -0
- data/app/workers/workarea/send_registry_creation_email.rb +12 -0
- data/app/workers/workarea/update_registry_items.rb +24 -0
- data/bin/rails +20 -0
- data/config/initializers/appends.rb +54 -0
- data/config/initializers/fields.rb +19 -0
- data/config/locales/en.yml +133 -0
- data/config/routes.rb +26 -0
- data/lib/workarea/mailer_previews/storefront/registry_mailer_preview.rb +25 -0
- data/lib/workarea/registries.rb +11 -0
- data/lib/workarea/registries/engine.rb +17 -0
- data/lib/workarea/registries/version.rb +5 -0
- data/test/dummy/config/application.rb +27 -0
- data/test/factories/workarea/registry.rb +67 -0
- data/test/integration/workarea/storefront/cart_item_registry_integration_test.rb +104 -0
- data/test/integration/workarea/storefront/checkout_registry_integration_test.rb +156 -0
- data/test/integration/workarea/storefront/registry_privacy_integration_test.rb +48 -0
- data/test/integration/workarea/storefront/user_registries_integration_test.rb +50 -0
- data/test/integration/workarea/storefront/user_registry_items_integration_test.rb +106 -0
- data/test/models/workarea/registry/item_test.rb +22 -0
- data/test/models/workarea/registry/public_search_test.rb +48 -0
- data/test/models/workarea/registry_test.rb +113 -0
- data/test/system/workarea/admin/registry_system_test.rb +20 -0
- data/test/workers/update_registry_items_test.rb +45 -0
- data/workarea-registries.gemspec +20 -0
- metadata +156 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0acac7c12d742655167b53830e3b8a8b978571e0
|
4
|
+
data.tar.gz: 054471ce79d92cace88608f10042ba4e5a47a60e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f000afae4ef2a49f6b268fbee66f22fc913be532177074af09e70caae679043d5c8d25f137ff97e3ff9fdd0506e6bcfe755d457af993a0fcc4a289541052d954
|
7
|
+
data.tar.gz: 3dafa13520a5a2b3cf5316cf83892a70e2e0f9b1ccee23978e920aa8aa0e878b52bd9261bb2a7c9d169359dbc384310e414019d84d934fbbed252020290f7f14
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
.bundle/
|
2
|
+
log/*.log
|
3
|
+
pkg/
|
4
|
+
test/dummy/db/*.sqlite3
|
5
|
+
test/dummy/db/*.sqlite3-journal
|
6
|
+
test/dummy/log/*.log
|
7
|
+
test/dummy/tmp/
|
8
|
+
.DS_Store
|
9
|
+
.byebug_history
|
10
|
+
.bundle/
|
11
|
+
.sass-cache/
|
12
|
+
Gemfile.lock
|
13
|
+
pkg/
|
14
|
+
test/dummy/tmp/
|
15
|
+
test/dummy/public/
|
16
|
+
log/*.log
|
17
|
+
test/dummy/log/*.log
|
18
|
+
test/dummy/db/*.sqlite3
|
19
|
+
test/dummy/db/*.sqlite3-journal
|
20
|
+
node_modules
|
21
|
+
test/reports
|
22
|
+
.rubocop-http*
|
data/Gemfile
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
git_source(:github) { |repo| "git@github.com:#{repo}.git" }
|
3
|
+
|
4
|
+
gemspec
|
5
|
+
|
6
|
+
# To use a debugger
|
7
|
+
# gem 'byebug', group: [:development, :test]
|
8
|
+
|
9
|
+
gem 'workarea', git: 'https://github.com/workarea-commerce/workarea.git', branch: 'v3.5-stable'
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2020 JurgenHahn
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# workarea-registries
|
data/Rakefile
ADDED
@@ -0,0 +1,58 @@
|
|
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 = 'Registries'
|
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/registries/version'
|
32
|
+
|
33
|
+
desc "Release version #{Workarea::Registries::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
|
+
|
41
|
+
system "git tag -a v#{Workarea::Registries::VERSION} -m 'Tagging #{Workarea::Registries::VERSION}'"
|
42
|
+
system 'git push origin HEAD --follow-tags'
|
43
|
+
|
44
|
+
system 'gem build workarea-registries.gemspec'
|
45
|
+
system "gem push workarea-registries-#{Workarea::Registries::VERSION}.gem --host #{host}"
|
46
|
+
system "rm workarea-registries-#{Workarea::Registries::VERSION}.gem"
|
47
|
+
end
|
48
|
+
|
49
|
+
desc 'Run the JavaScript tests'
|
50
|
+
ENV['TEASPOON_RAILS_ENV'] = File.expand_path('../test/dummy/config/environment', __FILE__)
|
51
|
+
task teaspoon: 'app:teaspoon'
|
52
|
+
|
53
|
+
desc 'Start a server at http://localhost:3000/teaspoon for JavaScript tests'
|
54
|
+
task :teaspoon_server do
|
55
|
+
Dir.chdir('test/dummy')
|
56
|
+
teaspoon_env = File.expand_path('../test/teaspoon_env.rb', __FILE__)
|
57
|
+
system "RAILS_ENV=test TEASPOON_ENV=#{teaspoon_env} rails s"
|
58
|
+
end
|
@@ -0,0 +1,4 @@
|
|
1
|
+
<svg fill="#000000" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg">
|
2
|
+
<path d="M0 0h24v24H0z" fill="none"/>
|
3
|
+
<path d="M20 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 14H4V8l8 5 8-5v10zm-8-7L4 6h16l-8 5z"/>
|
4
|
+
</svg>
|
@@ -0,0 +1 @@
|
|
1
|
+
<svg width="18" height="19" viewBox="0 0 18 19" xmlns="http://www.w3.org/2000/svg"><path d="M11.496 6.754a5.358 5.358 0 011.371 2.426 5.435 5.435 0 010 2.742 5.128 5.128 0 01-1.37 2.39l-2.392 2.391a5.128 5.128 0 01-2.39 1.371 5.435 5.435 0 01-2.742 0 5.174 5.174 0 01-2.409-1.388 5.174 5.174 0 01-1.388-2.409 5.435 5.435 0 010-2.742 5.128 5.128 0 011.37-2.39l1.337-1.336c.164-.164.357-.2.58-.106a.563.563 0 01.369.492 6.39 6.39 0 00.352 1.864c.07.21.023.398-.141.562l-.457.492a2.484 2.484 0 00-.756 1.776 2.42 2.42 0 00.72 1.793c.493.504 1.09.755 1.794.755.703 0 1.3-.246 1.793-.738l2.355-2.355c.492-.492.738-1.09.738-1.793 0-.703-.246-1.301-.738-1.793a2.53 2.53 0 00-.387-.317.473.473 0 01-.21-.421c-.024-.422.105-.774.386-1.055l.774-.738a.527.527 0 01.334-.159.597.597 0 01.369.088c.258.188.504.387.738.598zm4.957-4.957a5.358 5.358 0 011.371 2.426 5.435 5.435 0 010 2.742 5.128 5.128 0 01-1.37 2.39l-1.337 1.336c-.164.164-.357.2-.58.106a.563.563 0 01-.369-.492 6.39 6.39 0 00-.352-1.864.514.514 0 01.141-.562l.457-.492a2.484 2.484 0 00.756-1.776 2.417 2.417 0 00-.72-1.793 2.413 2.413 0 00-1.794-.756c-.703 0-1.3.247-1.793.739L8.508 6.156A2.441 2.441 0 007.77 7.95c0 .703.246 1.301.738 1.793.117.117.246.223.387.317.14.093.21.234.21.421.024.422-.105.774-.386 1.055l-.774.738a.527.527 0 01-.334.159.597.597 0 01-.369-.088 9.13 9.13 0 01-.738-.598A5.358 5.358 0 015.133 9.32a5.435 5.435 0 010-2.742 5.128 5.128 0 011.37-2.39l2.392-2.391a5.128 5.128 0 012.39-1.371 5.435 5.435 0 012.742 0 5.358 5.358 0 012.426 1.37z" fill-rule="evenodd"/></svg>
|
@@ -0,0 +1,49 @@
|
|
1
|
+
/**
|
2
|
+
* @namespace WORKAREA.addToRegistryButton
|
3
|
+
*/
|
4
|
+
WORKAREA.registerModule('addToRegistryButton', (function () {
|
5
|
+
'use strict';
|
6
|
+
|
7
|
+
var loadDialog = function(event) {
|
8
|
+
var $button = $(event.target),
|
9
|
+
$form = $button.closest('.product-details').find('.product-details__add-to-cart-form'),
|
10
|
+
data = $form.serialize();
|
11
|
+
|
12
|
+
event.preventDefault();
|
13
|
+
|
14
|
+
if (! $form.valid()) { return; }
|
15
|
+
|
16
|
+
WORKAREA.dialog.createFromUrl($button.attr('href') + '?' + data);
|
17
|
+
},
|
18
|
+
|
19
|
+
setupButtons = function($placeholder, user) {
|
20
|
+
var template = JST['workarea/storefront/registries/templates/add_to_registry_button'],
|
21
|
+
$addToRegistryButton;
|
22
|
+
|
23
|
+
if (!user.logged_in || user.registry_count < 1) { return; }
|
24
|
+
|
25
|
+
$addToRegistryButton = $(template(user));
|
26
|
+
|
27
|
+
$placeholder.replaceWith($addToRegistryButton);
|
28
|
+
$addToRegistryButton.on('click', loadDialog);
|
29
|
+
},
|
30
|
+
|
31
|
+
/**
|
32
|
+
* @method
|
33
|
+
* @name init
|
34
|
+
* @memberof WORKAREA.addToRegistryButton
|
35
|
+
*/
|
36
|
+
init = function ($scope) {
|
37
|
+
var $placeholder = $('[data-add-to-registry-button]', $scope);
|
38
|
+
|
39
|
+
if (_.isEmpty($placeholder)) { return; }
|
40
|
+
|
41
|
+
WORKAREA.currentUser.gettingUserData.done(
|
42
|
+
_.partial(setupButtons, $placeholder)
|
43
|
+
);
|
44
|
+
};
|
45
|
+
|
46
|
+
return {
|
47
|
+
init: init
|
48
|
+
};
|
49
|
+
}()));
|
data/app/assets/javascripts/workarea/storefront/registries/modules/copy_registry_url_button.js
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
/**
|
2
|
+
* @namespace WORKAREA.copyRegistryUrlButton
|
3
|
+
*/
|
4
|
+
|
5
|
+
WORKAREA.registerModule('copyRegistryUrlButton', (function () {
|
6
|
+
'use strict';
|
7
|
+
|
8
|
+
var copyURL = function (event) {
|
9
|
+
var registryUrl = $('[data-copy-registry-url-button]')[0].dataset.registryUrl,
|
10
|
+
temporaryId = 'temporary_copy_field',
|
11
|
+
temporaryInput = '<input type="text" class="visually-hidden" id="' + temporaryId + '" value="' + registryUrl + '">';
|
12
|
+
|
13
|
+
event.preventDefault();
|
14
|
+
|
15
|
+
$('body').append(temporaryInput);
|
16
|
+
$('#' + temporaryId).select();
|
17
|
+
|
18
|
+
try {
|
19
|
+
document.execCommand('copy');
|
20
|
+
WORKAREA.messages.insertMessage(
|
21
|
+
I18n.t('workarea.storefront.flash_messages.registry_url_copied'),
|
22
|
+
'success'
|
23
|
+
);
|
24
|
+
} catch(err) {
|
25
|
+
WORKAREA.messages.insertMessage(
|
26
|
+
I18n.t('workarea.storefront.flash_messages.registry_url_not_copied', { error: err.message }),
|
27
|
+
'error'
|
28
|
+
);
|
29
|
+
} finally {
|
30
|
+
$(temporaryId).remove();
|
31
|
+
}
|
32
|
+
},
|
33
|
+
|
34
|
+
/**
|
35
|
+
* @method
|
36
|
+
* @name init
|
37
|
+
* @memberof WORKAREA.copyRegistryUrlButton
|
38
|
+
*/
|
39
|
+
|
40
|
+
init = function ($scope) {
|
41
|
+
var $button = $('[data-copy-registry-url-button]', $scope);
|
42
|
+
|
43
|
+
if (_.isEmpty($button)) { return; }
|
44
|
+
|
45
|
+
$button.on('click', copyURL);
|
46
|
+
};
|
47
|
+
|
48
|
+
return {
|
49
|
+
init: init
|
50
|
+
};
|
51
|
+
}()));
|
@@ -0,0 +1,58 @@
|
|
1
|
+
/**
|
2
|
+
* @namespace WORKAREA.toggleRegistryAddress
|
3
|
+
*/
|
4
|
+
WORKAREA.registerModule('toggleRegistryAddress', (function () {
|
5
|
+
'use strict';
|
6
|
+
|
7
|
+
var toggleRegistryAddress = function ($option, $scope) {
|
8
|
+
var option = $option.data('registryAddressOption').option;
|
9
|
+
if (_.isEmpty($option)) { return; }
|
10
|
+
|
11
|
+
var $shippingAddressFields = $('.checkout-addresses__fields', $scope),
|
12
|
+
$registryAddressFields = $('[data-registry-checkout-addresses-fields]', $scope);
|
13
|
+
|
14
|
+
if (option === 'ship_to_registrant') {
|
15
|
+
$shippingAddressFields.addClass('hidden');
|
16
|
+
$registryAddressFields.removeClass('hidden');
|
17
|
+
toggleSameAsShipping($scope, false)
|
18
|
+
}
|
19
|
+
|
20
|
+
else if (option === 'ship_to_another_address') {
|
21
|
+
$shippingAddressFields.removeClass('hidden');
|
22
|
+
$registryAddressFields.addClass('hidden');
|
23
|
+
toggleSameAsShipping($scope, true)
|
24
|
+
}
|
25
|
+
},
|
26
|
+
|
27
|
+
toggleSameAsShipping = function($scope, checked) {
|
28
|
+
var $sameAsShippingCheckbox = $('#same_as_shipping', $scope),
|
29
|
+
$sameAsShippingContainer = $sameAsShippingCheckbox.parent();
|
30
|
+
|
31
|
+
$sameAsShippingCheckbox.prop('checked', checked)
|
32
|
+
.prop('disabled', !checked)
|
33
|
+
.trigger('change');
|
34
|
+
|
35
|
+
if (checked) {
|
36
|
+
$sameAsShippingContainer.removeClass('hidden');
|
37
|
+
} else {
|
38
|
+
$sameAsShippingContainer.addClass('hidden');
|
39
|
+
}
|
40
|
+
},
|
41
|
+
|
42
|
+
/**
|
43
|
+
* @method
|
44
|
+
* @name init
|
45
|
+
* @memberof WORKAREA.toggleRegistryAddress
|
46
|
+
*/
|
47
|
+
init = function ($scope) {
|
48
|
+
var $scope = $('.checkout-addresses__section--shipping', $scope)
|
49
|
+
|
50
|
+
$('[data-registry-address-option]', $scope).on('click', function(event) {
|
51
|
+
toggleRegistryAddress($(event.currentTarget), $scope);
|
52
|
+
});
|
53
|
+
};
|
54
|
+
|
55
|
+
return {
|
56
|
+
init: init
|
57
|
+
};
|
58
|
+
}()));
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Workarea
|
2
|
+
class Admin::RegistriesController < Admin::ApplicationController
|
3
|
+
required_permissions :orders
|
4
|
+
|
5
|
+
before_action :find_registry, except: :index
|
6
|
+
after_action :track_index_filters, only: :index
|
7
|
+
|
8
|
+
def index
|
9
|
+
search = Search::AdminRegistries.new(
|
10
|
+
params.merge(autocomplete: request.xhr?)
|
11
|
+
)
|
12
|
+
|
13
|
+
@search = Admin::SearchViewModel.new(search, view_model_options)
|
14
|
+
end
|
15
|
+
|
16
|
+
# Exists to support search result linkage
|
17
|
+
def show
|
18
|
+
redirect_to registries_path(q: "id:#{@registry.id}")
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def find_registry
|
24
|
+
model = Registry.find(params[:id])
|
25
|
+
@registry = Admin::RegistryViewModel.new(model, view_model_options)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Workarea
|
2
|
+
decorate Storefront::CartItemsController, with: :registries do
|
3
|
+
private
|
4
|
+
|
5
|
+
def item_params
|
6
|
+
@item_params_with_registry ||= super.merge(registry_params)
|
7
|
+
end
|
8
|
+
|
9
|
+
def registry_params
|
10
|
+
return {} unless params[:registry_id].present?
|
11
|
+
params.permit(:registry_id)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Workarea
|
2
|
+
module Storefront
|
3
|
+
class RegistriesController < ApplicationController
|
4
|
+
before_action :find_registry, only: :show
|
5
|
+
before_action :check_permissions, only: :show
|
6
|
+
|
7
|
+
def index
|
8
|
+
@page = Storefront::ContentViewModel.new(
|
9
|
+
Content.for('registries'),
|
10
|
+
view_model_options
|
11
|
+
)
|
12
|
+
end
|
13
|
+
|
14
|
+
def show
|
15
|
+
end
|
16
|
+
|
17
|
+
def search
|
18
|
+
if params[:registry_query].present?
|
19
|
+
@registries = Registry
|
20
|
+
.search(params[:registry_query])
|
21
|
+
.page(params[:page] || 1)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def find_registry
|
28
|
+
@registry = RegistryViewModel.wrap(
|
29
|
+
Registry.find_by(id: params[:id]),
|
30
|
+
{ :state => 'available' }
|
31
|
+
)
|
32
|
+
end
|
33
|
+
|
34
|
+
def check_permissions
|
35
|
+
if @registry.private? && registry_guest?
|
36
|
+
flash[:error] = t('workarea.storefront.flash_messages.private_registry')
|
37
|
+
redirect_to registries_path
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def registry_guest?
|
42
|
+
return true unless current_user
|
43
|
+
current_user.id.to_s != @registry.user_id
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
module Workarea
|
2
|
+
module Storefront
|
3
|
+
class Users::RegistriesController < ApplicationController
|
4
|
+
before_action :require_login
|
5
|
+
before_action :find_registry, except: [:index, :new, :create]
|
6
|
+
|
7
|
+
def index
|
8
|
+
@registries = Storefront::RegistryViewModel.wrap(
|
9
|
+
Registry.for_user(current_user.id).by_activity,
|
10
|
+
view_model_options
|
11
|
+
)
|
12
|
+
end
|
13
|
+
|
14
|
+
def new
|
15
|
+
@registry = RegistryViewModel.wrap(
|
16
|
+
Workarea::Registry.new,
|
17
|
+
view_model_options
|
18
|
+
)
|
19
|
+
end
|
20
|
+
|
21
|
+
def create
|
22
|
+
@registry = RegistryViewModel.wrap(
|
23
|
+
Workarea::Registry.new(registry_params.merge(address: registry_address_params)),
|
24
|
+
view_model_options
|
25
|
+
)
|
26
|
+
|
27
|
+
if @registry.save
|
28
|
+
flash[:success] = t('workarea.storefront.flash_messages.registry_created')
|
29
|
+
redirect_to users_registry_path(@registry)
|
30
|
+
else
|
31
|
+
flash[:error] = t('workarea.storefront.flash_messages.registry_not_created')
|
32
|
+
redirect_to users_account_path
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def show; end
|
37
|
+
|
38
|
+
def edit; end
|
39
|
+
|
40
|
+
def update
|
41
|
+
if @registry.update(registry_params.merge(address: registry_address_params))
|
42
|
+
flash[:success] = t('workarea.storefront.flash_messages.registry_updated')
|
43
|
+
else
|
44
|
+
flash[:error] = t('workarea.storefront.flash_messages.registry_not_updated')
|
45
|
+
end
|
46
|
+
|
47
|
+
redirect_to users_registry_path(@registry)
|
48
|
+
end
|
49
|
+
|
50
|
+
def destroy
|
51
|
+
@registry.destroy
|
52
|
+
|
53
|
+
flash[:success] =
|
54
|
+
t('workarea.storefront.flash_messages.registry_destroyed')
|
55
|
+
redirect_to users_account_path
|
56
|
+
end
|
57
|
+
|
58
|
+
private
|
59
|
+
|
60
|
+
def registry_params
|
61
|
+
params[:registry].permit(
|
62
|
+
:user_id,
|
63
|
+
:email,
|
64
|
+
:name,
|
65
|
+
:description,
|
66
|
+
:privacy,
|
67
|
+
:event_date
|
68
|
+
)
|
69
|
+
end
|
70
|
+
|
71
|
+
def registry_address_params
|
72
|
+
params[:registry_address].permit(
|
73
|
+
:first_name,
|
74
|
+
:last_name,
|
75
|
+
:company,
|
76
|
+
:street,
|
77
|
+
:street_2,
|
78
|
+
:city,
|
79
|
+
:country,
|
80
|
+
:region,
|
81
|
+
:postal_code,
|
82
|
+
:phone_number
|
83
|
+
)
|
84
|
+
end
|
85
|
+
|
86
|
+
def find_registry
|
87
|
+
@registry = RegistryViewModel.wrap(
|
88
|
+
Registry.find_by(id: params[:id], user_id: current_user.id),
|
89
|
+
view_model_options
|
90
|
+
)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|