Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite zones.js.coffee using Backbone.js #1766

Merged
merged 1 commit into from
Mar 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion backend/app/assets/javascripts/spree/backend/namespaces.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ _.extend(window.Spree, {
Collections: {},
Views: {
Order: {},
Cart: {}
Cart: {},
Zones: {}
}
})
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
//= require 'spree/backend/views/order/customer_select'
//= require 'spree/backend/views/order/summary'
//= require 'spree/backend/views/state_select'
//= require 'spree/backend/views/zones/form'
16 changes: 16 additions & 0 deletions backend/app/assets/javascripts/spree/backend/views/zones/form.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Spree.Views.Zones.Form = Backbone.View.extend({
events: {
'click [name="zone[kind]"]': 'render'
},

render: function() {
var kind = this.$('[name="zone[kind]"]:checked').val() || 'state';
this.$('[name="zone[kind]"]').val([kind]);

$('#state_members').toggleClass('hidden', kind !== 'state');
$('#state_members :input').prop('disabled', kind !== 'state');

$('#country_members').toggleClass('hidden', kind !== 'country');
$('#country_members :input').prop('disabled', kind !== 'country');
}
})
8 changes: 8 additions & 0 deletions backend/app/assets/javascripts/spree/backend/zone.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
$(function(){
if($('.js-zones-form').length) {
var view = new Spree.Views.Zones.Form({
el: $('.js-zones-form')
});
view.render()
}
});
43 changes: 0 additions & 43 deletions backend/app/assets/javascripts/spree/backend/zone.js.coffee

This file was deleted.

2 changes: 1 addition & 1 deletion backend/app/views/spree/admin/zones/_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="row">
<div class="row js-zones-form">
<div class="col-xs-5">

<div data-hook="admin_zone_form_fields">
Expand Down