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

Fixed SparkForm loading #5

Merged
merged 2 commits into from
Oct 30, 2024
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
1 change: 1 addition & 0 deletions resources/assets/js/auth/register-stripe.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import register from './../mixins/register.js';
import plans from './../mixins/plans.js';
import vat from './../mixins/vat.js';
import stripe from './../mixins/stripe.js';
import SparkForm from '../forms/form.js';

export default {
/**
Expand Down
50 changes: 0 additions & 50 deletions resources/assets/js/filters.js

This file was deleted.

11 changes: 0 additions & 11 deletions resources/assets/js/forms/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,6 @@ Spark.forms = {
updateTeamMember: {}
};


/**
* Load the SparkForm helper class.
*/
import('./form.js');

/**
* Define the SparkFormError collection class.
*/
import('./errors.js');

/**
* Add additional HTTP / form helpers to the Spark object.
*/
Expand Down
2 changes: 1 addition & 1 deletion resources/assets/js/forms/errors.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Spark form error collection class.
*/
window.SparkFormErrors = function () {
export default function () {
this.errors = {};

/**
Expand Down
4 changes: 3 additions & 1 deletion resources/assets/js/forms/form.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import SparkFormErrors from './errors.js';

/**
* SparkForm helper class. Used to set common properties on all forms.
*/
window.SparkForm = function (data) {
export default function (data) {
var form = this;
const initialData = data;

Expand Down
2 changes: 2 additions & 0 deletions resources/assets/js/kiosk/add-discount.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import SparkForm from '../forms/form.js';

function kioskAddDiscountForm () {
return {
type: 'amount',
Expand Down
2 changes: 2 additions & 0 deletions resources/assets/js/kiosk/announcements.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import SparkForm from '../forms/form.js';

var announcementsCreateForm = function () {
return {
body: '',
Expand Down
2 changes: 2 additions & 0 deletions resources/assets/js/kiosk/users.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import SparkForm from '../forms/form.js';

export default {
props: ['user'],

Expand Down
2 changes: 2 additions & 0 deletions resources/assets/js/mixins/subscriptions.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import SparkForm from '../forms/form.js';

/*
* This mixin is used by most of the subscription related screens to select plans
* and send subscription plan changes to the server. This contains helpers for
Expand Down
2 changes: 2 additions & 0 deletions resources/assets/js/settings/api/create-token.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import SparkForm from '../../forms/form.js';

export default {
props: ['availableAbilities'],

Expand Down
2 changes: 2 additions & 0 deletions resources/assets/js/settings/api/tokens.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import SparkForm from '../../forms/form.js';

export default {
props: ['tokens', 'availableAbilities'],

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import SparkForm from '../../forms/form.js';

export default {
props: ['user', 'team', 'billableType'],

Expand Down
2 changes: 2 additions & 0 deletions resources/assets/js/settings/payment-method/redeem-coupon.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import SparkForm from '../../forms/form.js';

export default {
props: ['user', 'team', 'billableType'],

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import SparkForm from '../../forms/form.js';

export default {
props: ['user', 'team', 'billableType'],

Expand Down
2 changes: 2 additions & 0 deletions resources/assets/js/settings/payment-method/update-vat-id.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import SparkForm from '../../forms/form.js';

export default {
props: ['user', 'team', 'billableType'],

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import SparkForm from '../../forms/form.js';

export default {
props: ['user'],

Expand Down
2 changes: 2 additions & 0 deletions resources/assets/js/settings/profile/update-profile-photo.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import SparkForm from '../../forms/form.js';

export default {
props: ['user'],

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import SparkForm from '../../forms/form.js';

export default {
props: ['user'],

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import SparkForm from '../../forms/form.js';

export default {
props: ['user'],

Expand Down
2 changes: 2 additions & 0 deletions resources/assets/js/settings/security/update-password.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import SparkForm from '../../forms/form.js';

export default {
/**
* The component's data.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import SparkForm from '../../forms/form.js';

export default {
props: ['user', 'team', 'billableType'],

Expand Down
2 changes: 2 additions & 0 deletions resources/assets/js/settings/subscription/subscribe-stripe.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import SparkForm from '../../forms/form.js';

export default {
props: ['user', 'team', 'plans', 'billableType'],

Expand Down
2 changes: 2 additions & 0 deletions resources/assets/js/settings/teams/create-team.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import SparkForm from '../../forms/form.js';

export default {
/**
* The component's data.
Expand Down
2 changes: 2 additions & 0 deletions resources/assets/js/settings/teams/current-teams.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import SparkForm from '../../forms/form.js';

export default {
props: ['user', 'teams'],

Expand Down
2 changes: 2 additions & 0 deletions resources/assets/js/settings/teams/send-invitation.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import SparkForm from '../../forms/form.js';

export default {
props: ['user', 'team', 'billableType', 'defaultRole'],

Expand Down
2 changes: 2 additions & 0 deletions resources/assets/js/settings/teams/team-members.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import SparkForm from '../../forms/form.js';

export default {
props: ['user', 'team'],

Expand Down
2 changes: 2 additions & 0 deletions resources/assets/js/settings/teams/update-team-name.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import SparkForm from '../../forms/form.js';

export default {
props: ['user', 'team'],

Expand Down
2 changes: 2 additions & 0 deletions resources/assets/js/settings/teams/update-team-photo.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import SparkForm from '../../forms/form.js';

export default {
props: ['user', 'team'],

Expand Down
48 changes: 46 additions & 2 deletions resources/assets/js/spark-bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import Promise from 'promise';
import Popper from 'popper.js';
import jQuery from 'jquery';
import mixin from './mixin.js';
import Dinero from 'dinero.js';
import SparkForm from './forms/form.js';

/*
* Load various JavaScript modules that assist Spark.
Expand Down Expand Up @@ -76,11 +78,53 @@ if ($('#spark-app').length > 0) {
* Load Vue Global Mixin.
*/
Vue.mixin(mixin);

/**
* Format the given date.
*/
Vue.filter('date', value => {
return moment.utc(value).local().format('MMMM Do, YYYY')
});

/**
* Format the given date as a timestamp.
*/
Vue.filter('datetime', value => {
return moment.utc(value).local().format('MMMM Do, YYYY h:mm A');
});

/**
* Define the Vue filters.
* Format the given date into a relative time.
*/
import('./filters.js');
Vue.filter('relative', value => {
return moment.utc(value).local().locale('en-short').fromNow();
});

/**
* Convert the first character to upper case.
*
* Source: https://github.com/vuejs/vue/blob/1.0/src/filters/index.js#L37
*/
Vue.filter('capitalize', value => {
if (!value && value !== 0) {
return '';
}

return value.toString().charAt(0).toUpperCase()
+ value.slice(1);
});

/**
* Format the given money value.
*/
Vue.filter('currency', value => {
return Dinero({
amount: Math.round(value * 100),
currency: window.Spark.currency
}).setLocale(window.Spark.currencyLocale).toFormat('$0,0.00');
});

window.SparkForm = SparkForm;

/**
* Load the Spark form utilities.
Expand Down
2 changes: 2 additions & 0 deletions resources/assets/js/spark.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import SparkForm from './forms/form.js';

/**
* Export the root Spark application.
*/
Expand Down