From 858a334d2fb9e3c61cd50c7ee1a726285d3e6c58 Mon Sep 17 00:00:00 2001 From: mrsaicharan1 Date: Mon, 17 Jun 2019 14:04:37 +0530 Subject: [PATCH 1/3] add intial mechanism for billing options(admin) Added fields for admin invoice contact Changed model names according to server added values for each field Used ES6 syntax Used attrs to access action closure Fixed additional info field remove redundant variable --- .../forms/admin/settings/billing.js | 133 +++++++++++++++++ app/controllers/admin/settings/billing.js | 18 +++ app/models/setting.js | 139 ++++++++++-------- app/router.js | 1 + app/routes/admin/settings/billing.js | 7 + app/templates/admin/settings.hbs | 3 + app/templates/admin/settings/billing.hbs | 3 + .../forms/admin/settings/billing.hbs | 77 ++++++++++ 8 files changed, 316 insertions(+), 65 deletions(-) create mode 100644 app/components/forms/admin/settings/billing.js create mode 100644 app/controllers/admin/settings/billing.js create mode 100644 app/routes/admin/settings/billing.js create mode 100644 app/templates/admin/settings/billing.hbs create mode 100644 app/templates/components/forms/admin/settings/billing.hbs diff --git a/app/components/forms/admin/settings/billing.js b/app/components/forms/admin/settings/billing.js new file mode 100644 index 00000000000..f264484b7c8 --- /dev/null +++ b/app/components/forms/admin/settings/billing.js @@ -0,0 +1,133 @@ +import Component from '@ember/component'; +import FormMixin from 'open-event-frontend/mixins/form'; +import { action } from '@ember/object'; + +export default class extends Component.extend(FormMixin) { + getValidationRules() { + return { + inline : true, + delay : false, + on : 'blur', + fields : { + adminBillingContactName: { + identifier : 'adminBillingContactName', + rules : [ + { + type : 'empty', + prompt : this.l10n.t('Please enter the Contact name') + } + ] + }, + adminBillingPhone: { + identifier : 'adminBillingPhone', + rules : [ + { + type : 'empty', + prompt : this.l10n.t('Please enter a phone number') + } + ] + }, + adminBillingEmail: { + identifier : 'adminBillingEmail', + rules : [ + { + type : 'empty', + prompt : this.l10n.t('Please enter the email') + }, + { + type : 'email', + prompt : this.l10n.t('Please enter a valid email address') + } + ] + }, + adminBillingCountry: { + identifier : 'adminBillingCountry', + rules : [ + { + type : 'empty', + prompt : this.l10n.t('Please enter the country') + } + ] + }, + + adminBillingTaxInfo: { + identifier : 'adminBillingTaxInfo', + rules : [ + { + type : 'empty', + prompt : this.l10n.t('Please enter the tax id') + } + ] + }, + adminCompany: { + identifier : 'adminCompany', + rules : [ + { + type : 'empty', + prompt : this.l10n.t('Please enter the company') + } + ] + }, + adminBillingAddress: { + identifier : 'adminBillingAddress', + rules : [ + { + type : 'empty', + prompt : this.l10n.t('Please enter the Address') + } + ] + }, + adminBillingCity: { + identifier : 'adminBillingCity', + rules : [ + { + type : 'empty', + prompt : this.l10n.t('Please enter the city') + } + ] + }, + + adminBillingZip: { + identifier : 'adminBillingZip', + rules : [ + { + type : 'empty', + prompt : this.l10n.t('Please enter the zip code') + }, + { + type : 'number', + prompt : this.l10n.t('Please enter a valid zip code') + } + ] + }, + adminBillingState: { + identifier : 'adminBillingState', + rules : [ + { + type : 'empty', + prompt : this.l10n.t('Please enter the state') + } + ] + }, + adminBillingAdditionalInfo: { + identifier : 'adminBillingAdditionalInfo', + rules : [ + { + type : 'empty', + prompt : this.l10n.t('Please enter additional info') + } + ] + } + } + }; + + } + + @action + submit() { + this.onValid(() => { + this.save(); + }); + } + +} diff --git a/app/controllers/admin/settings/billing.js b/app/controllers/admin/settings/billing.js new file mode 100644 index 00000000000..8ba6a868e92 --- /dev/null +++ b/app/controllers/admin/settings/billing.js @@ -0,0 +1,18 @@ +import Controller from '@ember/controller'; +import { timezones } from 'open-event-frontend/utils/dictionary/date-time'; +import { action } from '@ember/object'; + +export default class extends Controller { + timezones = timezones; + @action + async updateInvoiceModel() { + this.set('isLoading', true); + try { + await this.model.save(); + this.notify.success(this.l10n.t('Admin Billing info has been saved successfully')); + } catch (error) { + this.notify.error(this.l10n.t('An unexpected error has occurred. Settings not saved.')); + } + this.set('isLoading', false); + } +} diff --git a/app/models/setting.js b/app/models/setting.js index b228b8f5a25..d982b6f2ec7 100644 --- a/app/models/setting.js +++ b/app/models/setting.js @@ -8,71 +8,80 @@ export default ModelBase.extend({ * Attributes */ - appEnvironment : attr('string'), - appName : attr('string'), - tagline : attr('string'), - secret : attr('string'), - storagePlace : attr('string'), - awsKey : attr('string'), - awsSecret : attr('string'), - awsBucketName : attr('string'), - awsRegion : attr('string'), - gsKey : attr('string'), - gsSecret : attr('string'), - gsBucketName : attr('string'), - isGoogleRecaptchaEnabled : attr('boolean', { defaultValue: false }), - googleRecaptchaSitekey : attr('string'), - googleRecaptchaSecretkey : attr('string'), - googleClientId : attr('string'), - googleClientSecret : attr('string'), - fbClientId : attr('string'), - fbClientSecret : attr('string'), - twConsumerKey : attr('string'), - twConsumerSecret : attr('string'), - inClientId : attr('string'), - inClientSecret : attr('string'), - paypalMode : attr('string'), - paypalClient : attr('string'), - paypalSecret : attr('string'), - paypalSandboxClient : attr('string'), - paypalSandboxSecret : attr('string'), - alipaySecretKey : attr('string'), - alipayPublishableKey : attr('string'), - omiseMode : attr('string'), - omiseTestPublic : attr('string'), - omiseTestSecret : attr('string'), - omiseLivePublic : attr('string'), - omiseLiveSecret : attr('string'), - stripeClientId : attr('string'), - stripeSecretKey : attr('string'), - stripePublishableKey : attr('string'), - isPaypalActivated : attr('boolean'), - isStripeActivated : attr('boolean'), - isAliPayActivated : attr('boolean'), - isOmiseActivated : attr('boolean'), - emailService : attr('string'), - emailFrom : attr('string'), - emailFromName : attr('string'), - sendgridKey : attr('string'), - smtpHost : attr('string'), - smtpUsername : attr('string'), - smtpPassword : attr('string'), - smtpPort : attr('string'), - smtpEncryption : attr('string'), - analyticsKey : attr('string'), - googleUrl : attr('string'), - githubUrl : attr('string'), - twitterUrl : attr('string'), - supportUrl : attr('string'), - facebookUrl : attr('string'), - youtubeUrl : attr('string'), - androidAppUrl : attr('string'), - frontendUrl : attr('string'), - webAppUrl : attr('string'), - staticDomain : attr('string'), - cookiePolicy : attr('string'), - cookiePolicyLink : attr('string'), - + appEnvironment : attr('string'), + appName : attr('string'), + tagline : attr('string'), + secret : attr('string'), + storagePlace : attr('string'), + awsKey : attr('string'), + awsSecret : attr('string'), + awsBucketName : attr('string'), + awsRegion : attr('string'), + gsKey : attr('string'), + gsSecret : attr('string'), + gsBucketName : attr('string'), + googleClientId : attr('string'), + googleClientSecret : attr('string'), + fbClientId : attr('string'), + fbClientSecret : attr('string'), + twConsumerKey : attr('string'), + twConsumerSecret : attr('string'), + inClientId : attr('string'), + inClientSecret : attr('string'), + paypalMode : attr('string'), + paypalClient : attr('string'), + paypalSecret : attr('string'), + paypalSandboxClient : attr('string'), + paypalSandboxSecret : attr('string'), + alipaySecretKey : attr('string'), + alipayPublishableKey : attr('string'), + omiseMode : attr('string'), + omiseTestPublic : attr('string'), + omiseTestSecret : attr('string'), + omiseLivePublic : attr('string'), + omiseLiveSecret : attr('string'), + stripeClientId : attr('string'), + stripeSecretKey : attr('string'), + stripePublishableKey : attr('string'), + isAliPayActivated : attr('boolean'), + isPaypalActivated : attr('boolean'), + isStripeActivated : attr('boolean'), + isOmiseActivated : attr('boolean'), + emailService : attr('string'), + emailFrom : attr('string'), + emailFromName : attr('string'), + sendgridKey : attr('string'), + smtpHost : attr('string'), + smtpUsername : attr('string'), + smtpPassword : attr('string'), + smtpPort : attr('string'), + smtpEncryption : attr('string'), + analyticsKey : attr('string'), + googleUrl : attr('string'), + githubUrl : attr('string'), + twitterUrl : attr('string'), + supportUrl : attr('string'), + facebookUrl : attr('string'), + youtubeUrl : attr('string'), + androidAppUrl : attr('string'), + frontendUrl : attr('string'), + webAppUrl : attr('string'), + staticDomain : attr('string'), + cookiePolicy : attr('string'), + cookiePolicyLink : attr('string'), + invoiceSendingDay : attr('number'), + invoiceSendingTimezone : attr('string'), + adminBillingContactName : attr('string'), + adminBillingPhone : attr('string'), + adminBillingEmail : attr('string'), + adminBillingState : attr('string'), + adminBillingCountry : attr('string'), + adminBillingTaxInfo : attr('string'), + adminCompany : attr('string'), + adminBillingAddress : attr('string'), + adminBillingCity : attr('string'), + adminBillingZip : attr('string'), + adminBillingAdditionalInfo : attr('string'), /** * Computed properties */ diff --git a/app/router.js b/app/router.js index 5fa8f170cc2..3f571204d31 100644 --- a/app/router.js +++ b/app/router.js @@ -190,6 +190,7 @@ router.map(function() { this.route('analytics'); this.route('payment-gateway'); this.route('ticket-fees'); + this.route('billing'); }); this.route('modules'); this.route('content', function() { diff --git a/app/routes/admin/settings/billing.js b/app/routes/admin/settings/billing.js new file mode 100644 index 00000000000..a76e99f1b86 --- /dev/null +++ b/app/routes/admin/settings/billing.js @@ -0,0 +1,7 @@ +import Route from '@ember/routing/route'; + +export default class extends Route { + model() { + return this.modelFor('admin.settings'); + } +} diff --git a/app/templates/admin/settings.hbs b/app/templates/admin/settings.hbs index e39e63f0c31..8a833aa9b6a 100644 --- a/app/templates/admin/settings.hbs +++ b/app/templates/admin/settings.hbs @@ -20,6 +20,9 @@ {{#link-to 'admin.settings.ticket-fees' class='item'}} {{t 'Ticket Fees'}} {{/link-to}} + {{#link-to 'admin.settings.billing' class='item'}} + {{t 'Billing'}} + {{/link-to}} {{/tabbed-navigation}} diff --git a/app/templates/admin/settings/billing.hbs b/app/templates/admin/settings/billing.hbs new file mode 100644 index 00000000000..ce0f1256bd8 --- /dev/null +++ b/app/templates/admin/settings/billing.hbs @@ -0,0 +1,3 @@ +
+ {{forms/admin/settings/billing timezones=timezones model=model save=(action 'updateInvoiceModel')}} +
diff --git a/app/templates/components/forms/admin/settings/billing.hbs b/app/templates/components/forms/admin/settings/billing.hbs new file mode 100644 index 00000000000..e30c091a2b0 --- /dev/null +++ b/app/templates/components/forms/admin/settings/billing.hbs @@ -0,0 +1,77 @@ +
+

+ {{t 'Invoice Handling'}} +

+
+ {{#ui-dropdown class="selection" selected=model.invoiceSendingDay onChange=(action (mut model.invoiceSendingDay))}} + {{input type='hidden' id='invoiceSendingDay' value=model.invoiceSendingDay}} + +
{{t 'Invoices Sent Out'}}
+ + {{/ui-dropdown}} + + {{#ui-dropdown class="selection" selected=model.invoiceSendingTimezone onChange=(action (mut model.invoiceSendingTimezone))}} + {{input type='hidden' id='invoiceSendingTimezone' value=model.invoiceSendingTimezone}} + +
{{t 'Select timezone'}}
+ + {{/ui-dropdown}} +
+ +

+ {{t 'Invoice Contact'}} +

+
+ + {{input type='text' id='adminBillingContactName' value=model.adminBillingContactName}} +
+
+ + {{input type='text' id='adminBillingPhone' value=model.adminBillingPhone}} +
+
+ + {{input type='text' id='adminBillingEmail' value=model.adminBillingEmail}} +
+
+ + {{input type='text' id='adminBillingCountry' value=model.adminBillingCountry}} +
+
+ + {{input type='text' id='adminBillingTaxInfo' value=model.adminBillingTaxInfo}} +
+
+ + {{input type='text' id='adminCompany' value=model.adminCompany}} +
+
+ + {{textarea rows='2' id='adminBillingAddress' value=model.adminBillingAddress}} +
+
+ + {{input type='text' id='adminBillingCity' value=model.adminBillingCity}} +
+
+ + {{input type='text' id='adminBillingState' value=model.adminBillingState}} +
+
+ + {{input type='text' id='adminBillingZip' value=model.adminBillingZip}} +
+
+ + {{input type='text' id='adminBillingAdditionalInfo' value=model.adminBillingAdditionalInfo}} +
+ +
\ No newline at end of file From 31a825794a8a01f034aa9ae9acf0e53a4cb6f251 Mon Sep 17 00:00:00 2001 From: mrsaicharan1 Date: Sat, 13 Jul 2019 19:18:06 +0530 Subject: [PATCH 2/3] Fixed validations --- .../forms/admin/settings/billing.js | 30 +++---------------- app/controllers/admin/settings/billing.js | 10 +++++++ app/routes/admin/settings/billing.js | 3 ++ app/templates/admin/settings/billing.hbs | 2 +- .../forms/admin/settings/billing.hbs | 21 ++++++++++--- 5 files changed, 35 insertions(+), 31 deletions(-) diff --git a/app/components/forms/admin/settings/billing.js b/app/components/forms/admin/settings/billing.js index f264484b7c8..f313e55f731 100644 --- a/app/components/forms/admin/settings/billing.js +++ b/app/components/forms/admin/settings/billing.js @@ -1,5 +1,6 @@ import Component from '@ember/component'; import FormMixin from 'open-event-frontend/mixins/form'; +import { validPhoneNumber } from 'open-event-frontend/utils/validators'; import { action } from '@ember/object'; export default class extends Component.extend(FormMixin) { @@ -22,8 +23,9 @@ export default class extends Component.extend(FormMixin) { identifier : 'adminBillingPhone', rules : [ { - type : 'empty', - prompt : this.l10n.t('Please enter a phone number') + type : 'regExp', + value : validPhoneNumber, + prompt : this.l10n.t('Please enter a valid mobile number.') } ] }, @@ -93,34 +95,11 @@ export default class extends Component.extend(FormMixin) { { type : 'empty', prompt : this.l10n.t('Please enter the zip code') - }, - { - type : 'number', - prompt : this.l10n.t('Please enter a valid zip code') - } - ] - }, - adminBillingState: { - identifier : 'adminBillingState', - rules : [ - { - type : 'empty', - prompt : this.l10n.t('Please enter the state') - } - ] - }, - adminBillingAdditionalInfo: { - identifier : 'adminBillingAdditionalInfo', - rules : [ - { - type : 'empty', - prompt : this.l10n.t('Please enter additional info') } ] } } }; - } @action @@ -129,5 +108,4 @@ export default class extends Component.extend(FormMixin) { this.save(); }); } - } diff --git a/app/controllers/admin/settings/billing.js b/app/controllers/admin/settings/billing.js index 8ba6a868e92..70d36c8c4c6 100644 --- a/app/controllers/admin/settings/billing.js +++ b/app/controllers/admin/settings/billing.js @@ -1,9 +1,19 @@ import Controller from '@ember/controller'; import { timezones } from 'open-event-frontend/utils/dictionary/date-time'; +import { countries } from 'open-event-frontend/utils/dictionary/demography'; import { action } from '@ember/object'; +import { computed } from '@ember/object'; +import { paymentCountries } from 'open-event-frontend/utils/dictionary/payment'; +import { orderBy, filter } from 'lodash-es'; + export default class extends Controller { timezones = timezones; + @computed() + get countries() { + return orderBy(filter(countries, country => paymentCountries.includes(country.code)), 'name'); + } + payment @action async updateInvoiceModel() { this.set('isLoading', true); diff --git a/app/routes/admin/settings/billing.js b/app/routes/admin/settings/billing.js index a76e99f1b86..cb4c9b0c8ef 100644 --- a/app/routes/admin/settings/billing.js +++ b/app/routes/admin/settings/billing.js @@ -1,6 +1,9 @@ import Route from '@ember/routing/route'; export default class extends Route { + titleToken() { + return this.l10n.t('Admin Billing'); + } model() { return this.modelFor('admin.settings'); } diff --git a/app/templates/admin/settings/billing.hbs b/app/templates/admin/settings/billing.hbs index ce0f1256bd8..d9c38cdbed7 100644 --- a/app/templates/admin/settings/billing.hbs +++ b/app/templates/admin/settings/billing.hbs @@ -1,3 +1,3 @@
- {{forms/admin/settings/billing timezones=timezones model=model save=(action 'updateInvoiceModel')}} + {{forms/admin/settings/billing timezones=timezones countries=countries model=model save=(action 'updateInvoiceModel')}}
diff --git a/app/templates/components/forms/admin/settings/billing.hbs b/app/templates/components/forms/admin/settings/billing.hbs index e30c091a2b0..4c4046be084 100644 --- a/app/templates/components/forms/admin/settings/billing.hbs +++ b/app/templates/components/forms/admin/settings/billing.hbs @@ -42,9 +42,22 @@ {{input type='text' id='adminBillingEmail' value=model.adminBillingEmail}}
- - {{input type='text' id='adminBillingCountry' value=model.adminBillingCountry}} -
+ + {{#ui-dropdown class='search selection' selected=model.adminBillingCountry forceSelection=false + fullTextSearch=true}} + {{input type='hidden' id='country' value=model.adminBillingCountry}} + +
{{t 'Select country'}}
+ + {{/ui-dropdown}} +
{{input type='text' id='adminBillingTaxInfo' value=model.adminBillingTaxInfo}} @@ -62,7 +75,7 @@ {{input type='text' id='adminBillingCity' value=model.adminBillingCity}}
- + {{input type='text' id='adminBillingState' value=model.adminBillingState}}
From 8d3543ad8476293afd86dc3cbaca8f3653d71482 Mon Sep 17 00:00:00 2001 From: mrsaicharan1 Date: Mon, 15 Jul 2019 08:05:23 +0530 Subject: [PATCH 3/3] Fix travis --- app/templates/components/forms/admin/settings/billing.hbs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/templates/components/forms/admin/settings/billing.hbs b/app/templates/components/forms/admin/settings/billing.hbs index 4c4046be084..74501c451a7 100644 --- a/app/templates/components/forms/admin/settings/billing.hbs +++ b/app/templates/components/forms/admin/settings/billing.hbs @@ -42,10 +42,10 @@ {{input type='text' id='adminBillingEmail' value=model.adminBillingEmail}}
- + {{#ui-dropdown class='search selection' selected=model.adminBillingCountry forceSelection=false fullTextSearch=true}} - {{input type='hidden' id='country' value=model.adminBillingCountry}} + {{input type='hidden' id='country' value=model.adminBillingCountry}}
{{t 'Select country'}}
{{/each}}
- {{/ui-dropdown}} - + {{/ui-dropdown}} +
{{input type='text' id='adminBillingTaxInfo' value=model.adminBillingTaxInfo}}