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

Bugfix: Rename DoubleClickToEdit component and fix value tracking #33

Merged
merged 2 commits into from
May 4, 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
6 changes: 3 additions & 3 deletions src/components/admin/AdminBookingList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { BookingViewModel } from '../../models/interfaces';
import { TableConfiguration, TableDisplay } from '../TableDisplay';
import BookingTypeTag from '../utils/BookingTypeTag';
import DoneIcon from '../utils/DoneIcon';
import { DoubleClickToEdit } from '../utils/DoubleClickToEdit';
import { ClickToEdit } from '../utils/DoubleClickToEdit';
import FixedPriceStatusTag from '../utils/FixedPriceStatusTag';
import TableStyleLink from '../utils/TableStyleLink';
import { getBookingDateHeadingValue } from '../../lib/datetimeUtils';
Expand Down Expand Up @@ -75,7 +75,7 @@ const AdminBookingList: React.FC<Props> = ({

const bookingReferenceDisplayFn = (booking: BookingViewModel) => (
<>
<DoubleClickToEdit
<ClickToEdit
readonly={!allowEditInvoiceNumber}
onUpdate={(newInvoiceNumber: string) => {
if (!updateInvoiceNumber) {
Expand All @@ -86,7 +86,7 @@ const AdminBookingList: React.FC<Props> = ({
value={booking.invoiceNumber}
>
{replaceEmptyStringWithNull(booking.invoiceNumber) ?? <span className="text-muted">XXXXXXX</span>}
</DoubleClickToEdit>
</ClickToEdit>
</>
);

Expand Down
10 changes: 5 additions & 5 deletions src/components/bookings/equipmentLists/EquipmentListHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
} from '@fortawesome/free-solid-svg-icons';
import { EquipmentList, EquipmentListEntry, EquipmentListHeading } from '../../../models/interfaces/EquipmentList';
import { toIntOrUndefined, getRentalStatusName } from '../../../lib/utils';
import { DoubleClickToEdit } from '../../utils/DoubleClickToEdit';
import { ClickToEdit } from '../../utils/DoubleClickToEdit';
import { addVAT, formatCurrency, getEquipmentListPrice } from '../../../lib/pricingUtils';
import { PricePlan } from '../../../models/enums/PricePlan';
import {
Expand Down Expand Up @@ -114,7 +114,7 @@ const EquipmentListHeader: React.FC<Props> = ({
<>
<div className="d-flex">
<div className="flex-grow-1 mr-4" style={{ fontSize: '1.6em' }}>
<DoubleClickToEdit
<ClickToEdit
value={list.name}
onUpdate={(newValue: string) =>
saveList({
Expand All @@ -125,7 +125,7 @@ const EquipmentListHeader: React.FC<Props> = ({
readonly={readonly}
>
{list.name}
</DoubleClickToEdit>
</ClickToEdit>
</div>
<div className="d-flex">
<Button className="mr-2" variant="" onClick={() => toggleListContent()}>
Expand Down Expand Up @@ -358,7 +358,7 @@ const EquipmentListHeader: React.FC<Props> = ({
<div className="d-flex">
<div className="flex-grow-1">
<div className="mb-3" style={{ fontSize: '1.2em' }}>
<DoubleClickToEdit
<ClickToEdit
value={list.numberOfDays?.toString()}
inputType="number"
onUpdate={(newValue) =>
Expand All @@ -371,7 +371,7 @@ const EquipmentListHeader: React.FC<Props> = ({
className="mb-3 d-block"
>
{list.numberOfDays} {list.numberOfDays != 1 ? 'dagar' : 'dag'}
</DoubleClickToEdit>
</ClickToEdit>
</div>
</div>
{readonly ? null : (
Expand Down
30 changes: 15 additions & 15 deletions src/components/bookings/equipmentLists/EquipmentListTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { EquipmentList, EquipmentListEntry, EquipmentListHeading } from '../../.
import { TableConfiguration, TableDisplay } from '../../TableDisplay';
import { toIntOrUndefined, reduceSumFn, getResponseContentOrError } from '../../../lib/utils';
import EquipmentSearch, { ResultType } from '../../EquipmentSearch';
import { DoubleClickToEdit, DoubleClickToEditDropdown } from '../../utils/DoubleClickToEdit';
import { ClickToEdit, ClickToEditDropdown } from '../../utils/DoubleClickToEdit';
import {
addVAT,
addVATToPrice,
Expand Down Expand Up @@ -123,7 +123,7 @@ const EquipmentListTable: React.FC<Props> = ({
return (
<>
<div className="mb-0">
<DoubleClickToEdit
<ClickToEdit
value={heading.name}
onUpdate={(newValue) =>
saveListHeading({
Expand All @@ -138,10 +138,10 @@ const EquipmentListTable: React.FC<Props> = ({
<span className="text-muted ml-2">
({heading.listEntries.length} {heading.listEntries.length === 1 ? 'del' : 'delar'})
</span>
</DoubleClickToEdit>
</ClickToEdit>
</div>
<div className="mb-0 text-muted">
<DoubleClickToEdit
<ClickToEdit
value={heading.description}
onUpdate={(newValue) =>
saveListHeading({
Expand All @@ -159,7 +159,7 @@ const EquipmentListTable: React.FC<Props> = ({
{readonly ? null : 'Dubbelklicka för att lägga till en beskrivning'}
</span>
)}{' '}
</DoubleClickToEdit>
</ClickToEdit>
</div>
</>
);
Expand All @@ -170,7 +170,7 @@ const EquipmentListTable: React.FC<Props> = ({
return (
<>
<div className={'mb-0' + (entry.isHidden ? ' text-muted' : '')}>
<DoubleClickToEdit
<ClickToEdit
value={entry.name}
onUpdate={(newValue) =>
saveListEntry({ ...entry, name: newValue && newValue.length > 0 ? newValue : entry.name })
Expand Down Expand Up @@ -219,10 +219,10 @@ const EquipmentListTable: React.FC<Props> = ({
<FontAwesomeIcon icon={faDollarSign} className="ml-1" title="" />
</OverlayTrigger>
) : null}
</DoubleClickToEdit>
</ClickToEdit>
</div>
<div className="mb-0">
<DoubleClickToEdit
<ClickToEdit
value={entry.description}
onUpdate={(newValue) => saveListEntry({ ...entry, description: newValue })}
size="sm"
Expand All @@ -235,7 +235,7 @@ const EquipmentListTable: React.FC<Props> = ({
{readonly ? null : 'Dubbelklicka för att lägga till en beskrivning'}
</span>
)}
</DoubleClickToEdit>
</ClickToEdit>
</div>

<div className="mb-0 text-muted d-md-none">{EquipmentListEntryNumberOfHoursDisplayFn(viewModel)}</div>
Expand All @@ -259,7 +259,7 @@ const EquipmentListTable: React.FC<Props> = ({
}

return (
<DoubleClickToEdit
<ClickToEdit
value={entry.numberOfUnits?.toString()}
onUpdate={(newValue) =>
saveListEntry({ ...entry, numberOfUnits: toIntOrUndefined(newValue, true) ?? 0 })
Expand All @@ -268,7 +268,7 @@ const EquipmentListTable: React.FC<Props> = ({
readonly={readonly}
>
<span className={valueIsRelevant ? '' : 'text-muted'}>{entry.numberOfUnits} st</span>
</DoubleClickToEdit>
</ClickToEdit>
);
};

Expand All @@ -285,7 +285,7 @@ const EquipmentListTable: React.FC<Props> = ({
}

return (
<DoubleClickToEdit
<ClickToEdit
value={entry.numberOfHours.toString()}
onUpdate={(newValue) =>
saveListEntry({ ...entry, numberOfHours: toIntOrUndefined(newValue, true) ?? 0 })
Expand All @@ -294,7 +294,7 @@ const EquipmentListTable: React.FC<Props> = ({
readonly={readonly}
>
<span className={valueIsRelevant ? '' : 'text-muted'}>{entry.numberOfHours} h</span>
</DoubleClickToEdit>
</ClickToEdit>
);
};

Expand All @@ -319,7 +319,7 @@ const EquipmentListTable: React.FC<Props> = ({
};
return entry.equipment && entry.equipment.prices.length ? (
<span className={showPricesAsMuted ? 'text-muted' : ''}>
<DoubleClickToEditDropdown<EquipmentPrice>
<ClickToEditDropdown<EquipmentPrice>
options={
entry.equipmentPrice
? entry.equipment.prices
Expand All @@ -344,7 +344,7 @@ const EquipmentListTable: React.FC<Props> = ({
{entry.equipmentPrice && entry.equipment.prices.length > 1 ? (
<p className="text-muted mb-0">{entry.equipmentPrice.name}</p>
) : null}
</DoubleClickToEditDropdown>
</ClickToEditDropdown>
</span>
) : (
<span className={showPricesAsMuted ? 'text-muted' : ''}>{formatPrice(addVATToPrice(entry))}</span>
Expand Down
10 changes: 5 additions & 5 deletions src/components/bookings/timeEstimate/TimeEstimateList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { getResponseContentOrError, toIntOrUndefined, updateItemsInArrayById } f
import { toTimeEstimate } from '../../../lib/mappers/timeEstimate';
import { TimeEstimate } from '../../../models/interfaces/TimeEstimate';
import { useNotifications } from '../../../lib/useNotifications';
import { DoubleClickToEdit } from '../../utils/DoubleClickToEdit';
import { ClickToEdit } from '../../utils/DoubleClickToEdit';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import {
faAngleDown,
Expand Down Expand Up @@ -149,7 +149,7 @@ const TimeEstimateList: React.FC<Props> = ({ bookingId, readonly, defaultLaborHo
};

const TimeEstimateNameDisplayFn = (timeEstimate: TimeEstimate) => (
<DoubleClickToEdit
<ClickToEdit
value={timeEstimate.name}
onUpdate={(newValue) =>
updateTimeEstimates({
Expand All @@ -165,11 +165,11 @@ const TimeEstimateList: React.FC<Props> = ({ bookingId, readonly, defaultLaborHo
) : (
<span className="text-muted font-italic">Dubbelklicka för att lägga till en beskrivning</span>
)}
</DoubleClickToEdit>
</ClickToEdit>
);

const TimeEstimateNumberOfHoursDisplayFn = (timeEstimate: TimeEstimate) => (
<DoubleClickToEdit
<ClickToEdit
value={timeEstimate.numberOfHours?.toString()}
onUpdate={(newValue) =>
updateTimeEstimates({
Expand All @@ -185,7 +185,7 @@ const TimeEstimateList: React.FC<Props> = ({ bookingId, readonly, defaultLaborHo
) : (
timeEstimate.numberOfHours + ' h'
)}
</DoubleClickToEdit>
</ClickToEdit>
);

const TimeEstimateTotalPriceDisplayFn = (entry: TimeEstimate) => {
Expand Down
10 changes: 5 additions & 5 deletions src/components/bookings/timeReport/TimeReportList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { toTimeReport } from '../../../lib/mappers/timeReport';
import { addVAT, formatCurrency, getTimeReportPrice, getTotalTimeReportsPrice } from '../../../lib/pricingUtils';
import { useNotifications } from '../../../lib/useNotifications';
import { DoubleClickToEdit } from '../../utils/DoubleClickToEdit';
import { ClickToEdit } from '../../utils/DoubleClickToEdit';
import {
getNextSortIndex,
isFirst,
Expand Down Expand Up @@ -164,7 +164,7 @@ const TimeReportList: React.FC<Props> = ({ bookingId, currentUser, readonly, def

const TimeReportSpecificationDisplayFn = (timeReport: TimeReport) => (
<>
<DoubleClickToEdit
<ClickToEdit
value={timeReport.name}
onUpdate={(newValue) =>
updateTimeReports({
Expand All @@ -180,7 +180,7 @@ const TimeReportList: React.FC<Props> = ({ bookingId, currentUser, readonly, def
) : (
<span className="text-muted font-italic">Dubbelklicka för att lägga till en beskrivning</span>
)}
</DoubleClickToEdit>
</ClickToEdit>
{readonly ? (
<p className="text-muted">
{formatDatetime(timeReport.startDatetime)} - {formatDatetime(timeReport.endDatetime)}
Expand All @@ -194,7 +194,7 @@ const TimeReportList: React.FC<Props> = ({ bookingId, currentUser, readonly, def
);

const TimeReportBillableWorkingHoursDisplayFn = (timeReport: TimeReport) => (
<DoubleClickToEdit
<ClickToEdit
value={timeReport.billableWorkingHours?.toString()}
onUpdate={(newValue) =>
updateTimeReports({
Expand All @@ -206,7 +206,7 @@ const TimeReportList: React.FC<Props> = ({ bookingId, currentUser, readonly, def
readonly={readonly}
>
<TimeReportHourDisplay timeReport={timeReport} />
</DoubleClickToEdit>
</ClickToEdit>
);

const TimeReportUserIdDisplayFn = (timeReport: TimeReport) => (
Expand Down
Loading
Loading