-
-
Notifications
You must be signed in to change notification settings - Fork 730
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into update-readme
- Loading branch information
Showing
95 changed files
with
1,453 additions
and
462 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
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
53 changes: 29 additions & 24 deletions
53
app/assets/javascripts/admin/subscriptions/controllers/details_controller.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,38 +1,43 @@ | ||
angular.module("admin.subscriptions").controller "DetailsController", ($scope, $http, CreditCardResource, StatusMessage) -> | ||
angular.module("admin.subscriptions").controller "DetailsController", ($scope, $http, CustomerResource, StatusMessage) -> | ||
$scope.cardRequired = false | ||
|
||
$scope.registerNextCallback 'details', -> | ||
$scope.subscription_form.$submitted = true | ||
if $scope.subscription_details_form.$valid | ||
$scope.subscription_form.$setPristine() | ||
StatusMessage.clear() | ||
$scope.setView('address') | ||
else | ||
StatusMessage.display 'failure', t('admin.subscriptions.details.invalid_error') | ||
return unless $scope.validate() | ||
$scope.subscription_form.$setPristine() | ||
StatusMessage.clear() | ||
$scope.setView('address') | ||
|
||
$scope.$watch "subscription.customer_id", (newValue, oldValue) -> | ||
return if !newValue? | ||
$scope.loadAddresses(newValue) unless $scope.subscription.id? | ||
$scope.loadCreditCards(newValue) | ||
$scope.loadCustomer(newValue) unless $scope.subscription.id? | ||
|
||
$scope.$watch "subscription.payment_method_id", (newValue, oldValue) -> | ||
return if !newValue? | ||
paymentMethod = ($scope.paymentMethods.filter (pm) -> pm.id == newValue)[0] | ||
return unless paymentMethod? | ||
if paymentMethod.type == "Spree::Gateway::StripeConnect" | ||
$scope.cardRequired = true | ||
else | ||
$scope.cardRequired = false | ||
$scope.subscription.credit_card_id = null | ||
$scope.cardRequired = (paymentMethod.type == "Spree::Gateway::StripeConnect") | ||
$scope.loadCustomer() if $scope.cardRequired && !$scope.customer | ||
|
||
$scope.loadAddresses = (customer_id) -> | ||
$http.get("/admin/customers/#{customer_id}/addresses") | ||
.success (response) => | ||
delete response.bill_address.id | ||
delete response.ship_address.id | ||
angular.extend($scope.subscription.bill_address, response.bill_address) | ||
angular.extend($scope.subscription.ship_address, response.ship_address) | ||
$scope.shipAddressFromBilling() unless response.ship_address.address1? | ||
$scope.loadCustomer = -> | ||
params = { id: $scope.subscription.customer_id } | ||
params.ams_prefix = 'subscription' unless $scope.subscription.id | ||
$scope.customer = CustomerResource.get params, (response) -> | ||
for address in ['bill_address','ship_address'] | ||
return unless response[address] | ||
delete response[address].id | ||
return if $scope.subscription[address].address1? | ||
angular.extend($scope.subscription[address], response[address]) | ||
$scope.shipAddressFromBilling() unless response.ship_address?.address1? | ||
|
||
$scope.loadCreditCards = (customer_id) -> | ||
$scope.creditCards = CreditCardResource.index(customer_id: customer_id) | ||
$scope.validate = -> | ||
return true if $scope.subscription_details_form.$valid && $scope.creditCardOk() | ||
StatusMessage.display 'failure', t('admin.subscriptions.details.invalid_error') | ||
false | ||
|
||
$scope.creditCardOk = -> | ||
return true unless $scope.cardRequired | ||
return false unless $scope.customer | ||
return false unless $scope.customer.allow_charges | ||
return false unless $scope.customer.default_card_present | ||
true |
5 changes: 0 additions & 5 deletions
5
app/assets/javascripts/admin/subscriptions/services/credit_card_resource.js.coffee
This file was deleted.
Oops, something went wrong.
2 changes: 2 additions & 0 deletions
2
app/assets/javascripts/admin/subscriptions/services/customer_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,2 @@ | ||
angular.module("admin.subscriptions").factory 'CustomerResource', ($resource) -> | ||
$resource '/admin/customers/:id.json' |
17 changes: 17 additions & 0 deletions
17
app/assets/javascripts/admin/users/directives/resend_user_email_confirmation.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,17 @@ | ||
angular.module("admin.users").directive "resendUserEmailConfirmation", ($http) -> | ||
template: "{{ 'js.admin.resend_user_email_confirmation.' + status | t }}" | ||
scope: | ||
email: "@resendUserEmailConfirmation" | ||
link: (scope, element, attrs) -> | ||
sent = false | ||
scope.status = "resend" | ||
|
||
element.bind "click", -> | ||
return if sent | ||
scope.status = "sending" | ||
$http.post("/user/spree_user/confirmation", {spree_user: {email: scope.email}}).success (data) -> | ||
sent = true | ||
element.addClass "action--disabled" | ||
scope.status = "done" | ||
.error (data) -> | ||
scope.status = "failed" |
3 changes: 3 additions & 0 deletions
3
app/assets/javascripts/darkswarm/controllers/authorised_shops_controller.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,3 @@ | ||
angular.module("Darkswarm").controller "AuthorisedShopsCtrl", ($scope, Customers, Shops) -> | ||
$scope.customers = Customers.index() | ||
$scope.shopsByID = Shops.byID |
10 changes: 10 additions & 0 deletions
10
app/assets/javascripts/darkswarm/directives/help_modal.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,10 @@ | ||
Darkswarm.directive "helpModal", ($modal, $compile, $templateCache)-> | ||
restrict: 'A' | ||
scope: | ||
helpText: "@helpModal" | ||
|
||
link: (scope, elem, attrs, ctrl)-> | ||
compiled = $compile($templateCache.get('help-modal.html'))(scope) | ||
|
||
elem.on "click", => | ||
$modal.open(controller: ctrl, template: compiled, scope: scope, windowClass: 'help-modal small') |
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
20 changes: 20 additions & 0 deletions
20
app/assets/javascripts/darkswarm/services/customer.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,20 @@ | ||
angular.module("Darkswarm").factory 'Customer', ($resource, RailsFlashLoader) -> | ||
Customer = $resource('/api/customers/:id/:action.json', {}, { | ||
'index': | ||
method: 'GET' | ||
isArray: true | ||
'update': | ||
method: 'PUT' | ||
params: | ||
id: '@id' | ||
transformRequest: (data, headersGetter) -> | ||
angular.toJson(customer: data) | ||
}) | ||
|
||
Customer.prototype.update = -> | ||
@$update().then (response) => | ||
RailsFlashLoader.loadFlash({success: t('js.changes_saved')}) | ||
, (response) => | ||
RailsFlashLoader.loadFlash({error: response.data.error}) | ||
|
||
Customer |
14 changes: 14 additions & 0 deletions
14
app/assets/javascripts/darkswarm/services/customers.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,14 @@ | ||
angular.module("Darkswarm").factory 'Customers', (Customer) -> | ||
new class Customers | ||
all: [] | ||
byID: {} | ||
|
||
index: (params={}) -> | ||
return @all if @all.length | ||
Customer.index params, (data) => @load(data) | ||
@all | ||
|
||
load: (customers) -> | ||
for customer in customers | ||
@all.push customer | ||
@byID[customer.id] = customer |
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,13 @@ | ||
angular.module("Darkswarm").factory 'Shops', ($injector) -> | ||
new class Shops | ||
all: [] | ||
byID: {} | ||
|
||
constructor: -> | ||
if $injector.has('shops') | ||
@load($injector.get('shops')) | ||
|
||
load: (shops) -> | ||
for shop in shops | ||
@all.push shop | ||
@byID[shop.id] = shop |
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 @@ | ||
.row.help-icon | ||
.small-12.text-center | ||
%i.ofn-i_013-help | ||
.row.help-text | ||
.small-12.columns.text-center | ||
{{ helpText }} | ||
.row.text-center | ||
%button.primary.small{ ng: { click: '$close()' } } | ||
= t(:ok) |
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,3 +1,4 @@ | ||
@import 'plugins/font-awesome'; | ||
|
||
.icon-refund:before { @extend .icon-ok:before } | ||
.icon-credit:before { @extend .icon-ok:before } |
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 |
---|---|---|
|
@@ -28,6 +28,12 @@ | |
margin-bottom: 0px; | ||
} | ||
} | ||
|
||
.authorised_shops{ | ||
table { | ||
width: 100%; | ||
} | ||
} | ||
} | ||
|
||
.orders { | ||
|
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 @@ | ||
.help-modal { | ||
.help-text { | ||
font-size: 1rem; | ||
margin: 20px 0px; | ||
} | ||
.help-icon { | ||
font-size: 4rem; | ||
} | ||
} |
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 |
---|---|---|
|
@@ -87,6 +87,9 @@ button.success, .button.success { | |
&.tiny { | ||
padding: 0rem; | ||
margin: 0; | ||
} | ||
|
||
&.right { | ||
float: right; | ||
} | ||
|
||
|
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,13 @@ | ||
# Base controller for OFN's API | ||
# Includes the minimum machinery required by ActiveModelSerializers | ||
module Api | ||
class BaseController < Spree::Api::BaseController | ||
# Need to include these because Spree::Api::BaseContoller inherits | ||
# from ActionController::Metal rather than ActionController::Base | ||
# and they are required by ActiveModelSerializers | ||
include ActionController::Serialization | ||
include ActionController::UrlFor | ||
include Rails.application.routes.url_helpers | ||
use_renderers :json | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
module Api | ||
class CustomersController < BaseController | ||
def index | ||
@customers = current_api_user.customers.of_regular_shops | ||
render json: @customers, each_serializer: CustomerSerializer | ||
end | ||
|
||
def update | ||
@customer = Customer.find(params[:id]) | ||
authorize! :update, @customer | ||
|
||
if @customer.update_attributes(params[:customer]) | ||
render json: @customer, serializer: CustomerSerializer, status: 200 | ||
else | ||
invalid_resource!(@customer) | ||
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
Oops, something went wrong.