mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 13:50:31 +00:00
Fix :Forms Floating Actions.
This commit is contained in:
@@ -124,7 +124,7 @@ function ExpensesDataTable({
|
||||
text={formatMessage({ id: 'view_details' })}
|
||||
/>
|
||||
<MenuDivider />
|
||||
<If condition={!expense.published}>
|
||||
<If condition={!expense.is_published}>
|
||||
<MenuItem
|
||||
icon={<Icon icon={'arrow-to-top'} size={16} />}
|
||||
text={formatMessage({ id: 'publish_expense' })}
|
||||
@@ -209,7 +209,7 @@ function ExpensesDataTable({
|
||||
id: 'publish',
|
||||
Header: formatMessage({ id: 'publish' }),
|
||||
accessor: (r) => {
|
||||
return r.published ? (
|
||||
return !!r.is_published ? (
|
||||
<Tag minimal={true}>
|
||||
<T id={'published'} />
|
||||
</Tag>
|
||||
|
||||
@@ -90,7 +90,7 @@ export default function ExpenseFloatingFooter({
|
||||
return (
|
||||
<div className={classNames(CLASSES.PAGE_FORM_FLOATING_ACTIONS)}>
|
||||
{/* ----------- Save And Publish ----------- */}
|
||||
<If condition={!expense}>
|
||||
<If condition={!expense || !expensePublished}>
|
||||
<ButtonGroup>
|
||||
<Button
|
||||
disabled={isSubmitting}
|
||||
|
||||
@@ -129,6 +129,7 @@ function ExpenseForm({
|
||||
description: '',
|
||||
reference_no: '',
|
||||
currency_code: baseCurrency,
|
||||
is_published: '',
|
||||
categories: [...repeatValue(defaultCategory, MIN_LINES_NUMBER)],
|
||||
}),
|
||||
[defaultCategory],
|
||||
@@ -230,7 +231,7 @@ function ExpenseForm({
|
||||
|
||||
const form = {
|
||||
...values,
|
||||
publish: submitPayload.publish,
|
||||
is_published: submitPayload.publish,
|
||||
categories,
|
||||
};
|
||||
const saveExpense = (mdeiaIds) =>
|
||||
@@ -374,7 +375,7 @@ function ExpenseForm({
|
||||
onSubmitForm={submitForm}
|
||||
onResetForm={resetForm}
|
||||
expense={expenseId}
|
||||
expensePublished={true}
|
||||
expensePublished={values.is_published}
|
||||
/>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
@@ -21,7 +21,7 @@ const Schema = Yup.object().shape({
|
||||
.max(DATATYPES_LENGTH.TEXT)
|
||||
.nullable()
|
||||
.label(formatMessage({ id: 'description' })),
|
||||
publish: Yup.boolean().label(formatMessage({ id: 'publish' })),
|
||||
is_published: Yup.boolean(),
|
||||
categories: Yup.array().of(
|
||||
Yup.object().shape({
|
||||
index: Yup.number().min(1).max(DATATYPES_LENGTH.INT_10).nullable(),
|
||||
|
||||
@@ -89,7 +89,7 @@ export default function EstimateFloatingActions({
|
||||
return (
|
||||
<div className={classNames(CLASSES.PAGE_FORM_FLOATING_ACTIONS)}>
|
||||
{/* ----------- Save And Publish ----------- */}
|
||||
<If condition={!estimateId}>
|
||||
<If condition={!estimateId || !estimatePublished}>
|
||||
<ButtonGroup>
|
||||
<Button
|
||||
disabled={isSubmitting}
|
||||
|
||||
@@ -89,7 +89,7 @@ export default function InvoiceFloatingActions({
|
||||
return (
|
||||
<div className={classNames(CLASSES.PAGE_FORM_FLOATING_ACTIONS)}>
|
||||
{/* ----------- Save And Publish ----------- */}
|
||||
<If condition={!invoice}>
|
||||
<If condition={!invoice || !invoicePublished}>
|
||||
<ButtonGroup>
|
||||
<Button
|
||||
disabled={isSubmitting}
|
||||
|
||||
@@ -89,7 +89,7 @@ export default function ReceiptFormFloatingActions({
|
||||
return (
|
||||
<div className={classNames(CLASSES.PAGE_FORM_FLOATING_ACTIONS)}>
|
||||
{/* ----------- Save And Publish ----------- */}
|
||||
<If condition={!receiptId}>
|
||||
<If condition={!receiptId || !receiptPublished}>
|
||||
<ButtonGroup>
|
||||
<Button
|
||||
disabled={isSubmitting}
|
||||
|
||||
@@ -1,28 +1,28 @@
|
||||
import { Model } from 'objection';
|
||||
import TenantModel from 'models/TenantModel';
|
||||
import { viewRolesBuilder } from 'lib/ViewRolesBuilder';
|
||||
import Media from './Media';
|
||||
import { Model } from "objection";
|
||||
import TenantModel from "models/TenantModel";
|
||||
import { viewRolesBuilder } from "lib/ViewRolesBuilder";
|
||||
import Media from "./Media";
|
||||
|
||||
export default class Expense extends TenantModel {
|
||||
/**
|
||||
* Table name
|
||||
*/
|
||||
static get tableName() {
|
||||
return 'expenses_transactions';
|
||||
return "expenses_transactions";
|
||||
}
|
||||
|
||||
/**
|
||||
* Account transaction reference type.
|
||||
*/
|
||||
static get referenceType() {
|
||||
return 'Expense';
|
||||
return "Expense";
|
||||
}
|
||||
|
||||
/**
|
||||
* Model timestamps.
|
||||
*/
|
||||
get timestamps() {
|
||||
return ['createdAt', 'updatedAt'];
|
||||
return ["createdAt", "updatedAt"];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -33,11 +33,18 @@ export default class Expense extends TenantModel {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
static get media () {
|
||||
static get media() {
|
||||
return true;
|
||||
}
|
||||
|
||||
static get virtualAttributes() {
|
||||
return ["isPublished"];
|
||||
}
|
||||
isPublished() {
|
||||
return Boolean(this.publishedAt);
|
||||
}
|
||||
|
||||
/**
|
||||
* Model modifiers.
|
||||
@@ -46,28 +53,28 @@ export default class Expense extends TenantModel {
|
||||
return {
|
||||
filterByDateRange(query, startDate, endDate) {
|
||||
if (startDate) {
|
||||
query.where('date', '>=', startDate);
|
||||
query.where("date", ">=", startDate);
|
||||
}
|
||||
if (endDate) {
|
||||
query.where('date', '<=', endDate);
|
||||
query.where("date", "<=", endDate);
|
||||
}
|
||||
},
|
||||
filterByAmountRange(query, from, to) {
|
||||
if (from) {
|
||||
query.where('amount', '>=', from);
|
||||
query.where("amount", ">=", from);
|
||||
}
|
||||
if (to) {
|
||||
query.where('amount', '<=', to);
|
||||
query.where("amount", "<=", to);
|
||||
}
|
||||
},
|
||||
filterByExpenseAccount(query, accountId) {
|
||||
if (accountId) {
|
||||
query.where('expense_account_id', accountId);
|
||||
query.where("expense_account_id", accountId);
|
||||
}
|
||||
},
|
||||
filterByPaymentAccount(query, accountId) {
|
||||
if (accountId) {
|
||||
query.where('payment_account_id', accountId);
|
||||
query.where("payment_account_id", accountId);
|
||||
}
|
||||
},
|
||||
viewRolesBuilder(query, conditionals, expression) {
|
||||
@@ -80,41 +87,41 @@ export default class Expense extends TenantModel {
|
||||
* Relationship mapping.
|
||||
*/
|
||||
static get relationMappings() {
|
||||
const Account = require('models/Account');
|
||||
const ExpenseCategory = require('models/ExpenseCategory');
|
||||
const Media = require('models/Media');
|
||||
const Account = require("models/Account");
|
||||
const ExpenseCategory = require("models/ExpenseCategory");
|
||||
const Media = require("models/Media");
|
||||
|
||||
return {
|
||||
paymentAccount: {
|
||||
relation: Model.BelongsToOneRelation,
|
||||
modelClass: Account.default,
|
||||
join: {
|
||||
from: 'expenses_transactions.paymentAccountId',
|
||||
to: 'accounts.id',
|
||||
from: "expenses_transactions.paymentAccountId",
|
||||
to: "accounts.id",
|
||||
},
|
||||
},
|
||||
categories: {
|
||||
relation: Model.HasManyRelation,
|
||||
modelClass: ExpenseCategory.default,
|
||||
join: {
|
||||
from: 'expenses_transactions.id',
|
||||
to: 'expense_transaction_categories.expenseId',
|
||||
from: "expenses_transactions.id",
|
||||
to: "expense_transaction_categories.expenseId",
|
||||
},
|
||||
},
|
||||
media: {
|
||||
relation: Model.ManyToManyRelation,
|
||||
modelClass: Media.default,
|
||||
join: {
|
||||
from: 'expenses_transactions.id',
|
||||
from: "expenses_transactions.id",
|
||||
through: {
|
||||
from: 'media_links.model_id',
|
||||
to: 'media_links.media_id',
|
||||
from: "media_links.model_id",
|
||||
to: "media_links.media_id",
|
||||
},
|
||||
to: 'media.id',
|
||||
to: "media.id",
|
||||
},
|
||||
filter(query) {
|
||||
query.where('model_name', 'Expense');
|
||||
}
|
||||
query.where("model_name", "Expense");
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -125,51 +132,50 @@ export default class Expense extends TenantModel {
|
||||
static get fields() {
|
||||
return {
|
||||
payment_date: {
|
||||
label: 'Payment date',
|
||||
column: 'payment_date',
|
||||
columnType: 'date',
|
||||
label: "Payment date",
|
||||
column: "payment_date",
|
||||
columnType: "date",
|
||||
},
|
||||
payment_account: {
|
||||
label: 'Payment account',
|
||||
column: 'payment_account_id',
|
||||
relation: 'accounts.id',
|
||||
optionsResource: 'account',
|
||||
label: "Payment account",
|
||||
column: "payment_account_id",
|
||||
relation: "accounts.id",
|
||||
optionsResource: "account",
|
||||
},
|
||||
amount: {
|
||||
label: 'Amount',
|
||||
column: 'total_amount',
|
||||
columnType: 'number'
|
||||
label: "Amount",
|
||||
column: "total_amount",
|
||||
columnType: "number",
|
||||
},
|
||||
currency_code: {
|
||||
label: 'Currency',
|
||||
column: 'currency_code',
|
||||
optionsResource: 'currency',
|
||||
label: "Currency",
|
||||
column: "currency_code",
|
||||
optionsResource: "currency",
|
||||
},
|
||||
reference_no: {
|
||||
label: 'Reference No.',
|
||||
column: 'reference_no',
|
||||
columnType: 'string',
|
||||
label: "Reference No.",
|
||||
column: "reference_no",
|
||||
columnType: "string",
|
||||
},
|
||||
description: {
|
||||
label: 'Description',
|
||||
column: 'description',
|
||||
columnType: 'string',
|
||||
label: "Description",
|
||||
column: "description",
|
||||
columnType: "string",
|
||||
},
|
||||
published: {
|
||||
label: 'Published',
|
||||
column: 'published',
|
||||
|
||||
label: "Published",
|
||||
column: "published",
|
||||
},
|
||||
user: {
|
||||
label: 'User',
|
||||
column: 'user_id',
|
||||
relation: 'users.id',
|
||||
relationColumn: 'users.id',
|
||||
label: "User",
|
||||
column: "user_id",
|
||||
relation: "users.id",
|
||||
relationColumn: "users.id",
|
||||
},
|
||||
created_at: {
|
||||
label: 'Created at',
|
||||
column: 'created_at',
|
||||
columnType: 'date',
|
||||
label: "Created at",
|
||||
column: "created_at",
|
||||
columnType: "date",
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user