diff --git a/app/Http/Controllers/PreferencesController.php b/app/Http/Controllers/PreferencesController.php index dde531cafa..6953c603dc 100644 --- a/app/Http/Controllers/PreferencesController.php +++ b/app/Http/Controllers/PreferencesController.php @@ -49,7 +49,7 @@ class PreferencesController extends Controller $this->middleware( function ($request, $next) { - app('view')->share('title', (string) trans('firefly.preferences')); + app('view')->share('title', (string)trans('firefly.preferences')); app('view')->share('mainTitleIcon', 'fa-gear'); return $next($request); @@ -111,7 +111,7 @@ class PreferencesController extends Controller Log::error($e->getMessage()); $locales = []; } - $locales = ['equal' => (string) trans('firefly.equal_to_language')] + $locales; + $locales = ['equal' => (string)trans('firefly.equal_to_language')] + $locales; // an important fallback is that the frontPageAccount array gets refilled automatically // when it turns up empty. if (0 === count($frontPageAccounts->data)) { @@ -151,7 +151,7 @@ class PreferencesController extends Controller $frontPageAccounts = []; if (is_array($request->get('frontPageAccounts')) && count($request->get('frontPageAccounts')) > 0) { foreach ($request->get('frontPageAccounts') as $id) { - $frontPageAccounts[] = (int) $id; + $frontPageAccounts[] = (int)$id; } app('preferences')->set('frontPageAccounts', $frontPageAccounts); } @@ -164,14 +164,14 @@ class PreferencesController extends Controller session()->forget('range'); // custom fiscal year - $customFiscalYear = 1 === (int) $request->get('customFiscalYear'); - $fiscalYearStart = date('m-d', strtotime((string) $request->get('fiscalYearStart'))); + $customFiscalYear = 1 === (int)$request->get('customFiscalYear'); + $fiscalYearStart = date('m-d', strtotime((string)$request->get('fiscalYearStart'))); app('preferences')->set('customFiscalYear', $customFiscalYear); app('preferences')->set('fiscalYearStart', $fiscalYearStart); // save page size: app('preferences')->set('listPageSize', 50); - $listPageSize = (int) $request->get('listPageSize'); + $listPageSize = (int)$request->get('listPageSize'); if ($listPageSize > 0 && $listPageSize < 1337) { app('preferences')->set('listPageSize', $listPageSize); } @@ -207,10 +207,12 @@ class PreferencesController extends Controller 'notes' => isset($setOptions['notes']), 'attachments' => isset($setOptions['attachments']), 'external_uri' => isset($setOptions['external_uri']), + 'location' => isset($setOptions['location']), + 'links' => isset($setOptions['links']), ]; app('preferences')->set('transaction_journal_optional_fields', $optionalTj); - session()->flash('success', (string) trans('firefly.saved_preferences')); + session()->flash('success', (string)trans('firefly.saved_preferences')); app('preferences')->mark(); // telemetry: user language preference + default language. diff --git a/frontend/package.json b/frontend/package.json index 0a6c38c324..d1157037d0 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -19,7 +19,7 @@ "node-forge": ">=0.10.0", "resolve-url-loader": "^3.1.2", "sass": "^1.32.2", - "sass-loader": "^11.0.1", + "sass-loader": "^10.1.1", "vue": "^2.6.12", "vue-i18n": "^8.22.2", "vue-template-compiler": "^2.6.12" diff --git a/frontend/src/components/store/modules/transactions/create.js b/frontend/src/components/store/modules/transactions/create.js index a6d02b6ced..013aedf284 100644 --- a/frontend/src/components/store/modules/transactions/create.js +++ b/frontend/src/components/store/modules/transactions/create.js @@ -55,7 +55,8 @@ const state = () => ({ piggy_bank: [], internal_reference: [], external_url: [], - notes: [] + notes: [], + location: [] }, defaultTransaction: { // basic diff --git a/frontend/src/components/transactions/Create.vue b/frontend/src/components/transactions/Create.vue index 859b851777..828a717466 100644 --- a/frontend/src/components/transactions/Create.vue +++ b/frontend/src/components/transactions/Create.vue @@ -22,7 +22,7 @@
- +
@@ -116,7 +117,7 @@ export default { created() { this.storeAllowedOpposingTypes(); this.storeAccountToTransaction(); - this.storeCustomDateFields(); + this.storeCustomFields(); this.addTransaction(); }, data() { @@ -125,6 +126,9 @@ export default { errorMessage: '', successMessage: '', + // custom fields, useful for components: + customFields: [], + // states for the form (makes sense right) enableSubmit: true, createAnother: false, @@ -155,7 +159,6 @@ export default { ...mapGetters([ 'transactionType', 'transactions', - 'customDateFields', 'date', 'groupTitle' ]) @@ -203,27 +206,9 @@ export default { * it should be done via the create.js Vue store because multiple components are interested in the * user's custom transaction fields. */ - storeCustomDateFields: function () { + storeCustomFields: function () { axios.get('./api/v1/preferences/transaction_journal_optional_fields').then(response => { - let fields = response.data.data.attributes.data; - let allDateFields = ['interest_date', 'book_date', 'process_date', 'due_date', 'payment_date', 'invoice_date']; - let selectedDateFields = { - interest_date: false, - book_date: false, - process_date: false, - due_date: false, - payment_date: false, - invoice_date: false, - }; - for (let key in fields) { - if (fields.hasOwnProperty(key)) { - if (-1 !== allDateFields.indexOf(key)) { - selectedDateFields[key] = fields[key]; - } - } - } - // see we already store it in the store, so this would be an easy change. - this.$store.commit('transactions/create/setCustomDateFields', selectedDateFields); + this.customFields = response.data.data.attributes.data; }); }, /** diff --git a/frontend/src/components/transactions/SplitForm.vue b/frontend/src/components/transactions/SplitForm.vue index 41e8762ddb..ca99a9ca17 100644 --- a/frontend/src/components/transactions/SplitForm.vue +++ b/frontend/src/components/transactions/SplitForm.vue @@ -100,6 +100,7 @@
@@ -164,12 +165,12 @@
-
+

- {{ $t('firefly.transaction_journal_meta') }} + {{ $t('firefly.transaction_journal_extra') }} ({{ index + 1 }} / {{ count }})

@@ -182,17 +183,20 @@ :index="index" v-model="transaction.internal_reference" :errors="transaction.errors.internal_reference" + :custom-fields.sync="customFields" />
@@ -204,9 +208,20 @@ :transaction_journal_id="transaction.transaction_journal_id" :submitted_transaction="submittedTransaction" v-model="transaction.attachments" + :custom-fields.sync="customFields" + /> + - +
@@ -242,6 +257,7 @@ import TransactionLinks from "./TransactionLinks"; import TransactionAttachments from "./TransactionAttachments"; import SplitPills from "./SplitPills"; import {createNamespacedHelpers} from "vuex"; +import TransactionLocation from "./TransactionLocation"; const {mapState, mapGetters, mapActions, mapMutations} = createNamespacedHelpers('transactions/create') @@ -251,13 +267,35 @@ export default { 'transaction', 'split', 'count', + 'customFields', // for custom transaction form fields. 'index', 'submittedTransaction' // need to know if transaction is submitted. ], computed: { - ...mapGetters(['transactionType',]) + ...mapGetters(['transactionType',]), + hasMetaFields: function () { + let requiredFields = [ + 'internal_reference', + 'notes', + 'attachments', + 'external_uri', + 'location', + 'links', + ]; + for (let field in this.customFields) { + if (this.customFields.hasOwnProperty(field)) { + if (requiredFields.includes(field)) { + if (true === this.customFields[field]) { + return true; + } + } + } + } + return false; + } }, components: { + TransactionLocation, SplitPills, TransactionAttachments, TransactionNotes, diff --git a/frontend/src/components/transactions/TransactionAttachments.vue b/frontend/src/components/transactions/TransactionAttachments.vue index c0c56fc02b..3688ea3b20 100644 --- a/frontend/src/components/transactions/TransactionAttachments.vue +++ b/frontend/src/components/transactions/TransactionAttachments.vue @@ -19,7 +19,7 @@ -->