Skip to content

Commit

Permalink
Merge branch 'develop' into TASK-304-work-hour-conversion-in-worker-i…
Browse files Browse the repository at this point in the history
…nput
  • Loading branch information
Qwebeck authored Mar 19, 2021
2 parents b82c730 + 5f1dc82 commit 7f56a2d
Show file tree
Hide file tree
Showing 18 changed files with 458 additions and 318 deletions.
29 changes: 19 additions & 10 deletions src/api/local-storage-provider.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
} from "../common-models/schedule-data.model";

import {
getRevisionTypeFromKey,
MonthRevision,
PersistenceStoreProvider,
RevisionKey,
Expand All @@ -37,7 +38,6 @@ export class LocalStorageProvider extends PersistenceStoreProvider {
super();
this.storage = new PouchDB(DATABASE_NAME);
}

async reloadDb(): Promise<void> {
try {
await this.storage.destroy();
Expand All @@ -61,10 +61,16 @@ export class LocalStorageProvider extends PersistenceStoreProvider {
const oppositeRevision = await this.getMonthRevision(
monthDataModel.scheduleKey.getRevisionKey(oppositeRevisionType)
);
const isMonthInFuture = VerboseDateHelper.isMonthInFuture(
monthDataModel.scheduleKey.month,
monthDataModel.scheduleKey.year
);

if (
_.isNil(oppositeRevision) ||
oppositeRevision.isAutoGenerated ||
oppositeRevisionType === "actual"
oppositeRevisionType === "actual" ||
isMonthInFuture
) {
await this.saveMonthRevision(oppositeRevisionType, monthDataModel);
}
Expand All @@ -86,6 +92,7 @@ export class LocalStorageProvider extends PersistenceStoreProvider {
// eslint-disable-next-line no-console
error.status !== 404 && console.error(error);
}

const monthRev: MonthRevision = {
_id: revisionKey,
data: monthDataModel,
Expand All @@ -112,8 +119,11 @@ export class LocalStorageProvider extends PersistenceStoreProvider {
);

if (daysMissingFromNextMonth !== 0) {
const nextMonthRevisionKey = getScheduleKey(scheduleDataModel).nextMonthKey.getRevisionKey(
type
);
await this.updateMonthPartBasedOnScheduleDM(
getScheduleKey(scheduleDataModel).nextMonthKey.getRevisionKey(type),
nextMonthRevisionKey,
scheduleDataModel,
daysMissingFromNextMonth,
"HEAD"
Expand All @@ -128,8 +138,8 @@ export class LocalStorageProvider extends PersistenceStoreProvider {
updatePosition: ArrayPositionPointer
): Promise<void> {
try {
const document = await this.storage.get(revisionKey);
const updatedMonthDataModel = document.data;
const updatedMonthDataModel = await this.getMonthRevision(revisionKey);
if (_.isNil(updatedMonthDataModel)) return;

const newShifts = _.cloneDeep(updatedMonthDataModel.shifts);

Expand Down Expand Up @@ -160,11 +170,10 @@ export class LocalStorageProvider extends PersistenceStoreProvider {
};

validateMonthDM(updatedMonthDataModel);
this.storage.put({
_rev: document._rev,
_id: revisionKey,
data: updatedMonthDataModel,
});
await this.saveBothMonthRevisionsIfNeeded(
getRevisionTypeFromKey(revisionKey),
updatedMonthDataModel
);
} catch (error) {
// eslint-disable-next-line no-console
error.status !== 404 && console.error(error);
Expand Down
50 changes: 17 additions & 33 deletions src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ import ScssVars from "./assets/styles/styles/custom/_variables.module.scss";
import { ApplicationStateModel } from "./state/models/application-state.model";
import { ScheduleKey } from "./api/persistance-store.model";
import { AppMode, useAppConfig } from "./state/app-config-context";
import * as Sentry from "@sentry/react";
import AppErrorModal from "./components/common-components/modal/app-error-modal/app-error.modal.component";
import { cropScheduleDMToMonthDM } from "./logic/schedule-container-convertion/schedule-container-convertion";

const useStyles = makeStyles(() => ({
Expand Down Expand Up @@ -104,39 +102,25 @@ function App(): JSX.Element {
fetchGlobalState();
}, [fetchGlobalState]);

const [open, setIsOpen] = useState(false);
const fallback = useCallback(
({ resetError }): JSX.Element => (
<AppErrorModal onClick={resetError} open={open} setOpen={setIsOpen} />
),
[open, setIsOpen]
);

const onError = useCallback((): void => {
setIsOpen(true);
}, [setIsOpen]);

return (
<Sentry.ErrorBoundary fallback={fallback} onError={onError}>
<NotificationProvider>
<JiraLikeDrawerProvider>
<Switch>
<Route path="/">
<Box className={classes.root}>
<Box className={classes.content}>
<HeaderComponent />
<RouteButtonsComponent tabs={tabs} disabled={disableRouteButtons} />
</Box>
<Box className={classes.drawer}>
<JiraLikeDrawer width={690} />
</Box>
<NotificationProvider>
<JiraLikeDrawerProvider>
<Switch>
<Route path="/">
<Box className={classes.root}>
<Box className={classes.content}>
<HeaderComponent />
<RouteButtonsComponent tabs={tabs} disabled={disableRouteButtons} />
</Box>
<Box className={classes.drawer}>
<JiraLikeDrawer width={690} />
</Box>
{isElectron() ? <></> : <NetlifyProFooter />}
</Route>
</Switch>
</JiraLikeDrawerProvider>
</NotificationProvider>
</Sentry.ErrorBoundary>
</Box>
{isElectron() ? <></> : <NetlifyProFooter />}
</Route>
</Switch>
</JiraLikeDrawerProvider>
</NotificationProvider>
);
}

Expand Down
64 changes: 39 additions & 25 deletions src/assets/styles/styles/custom/_autocomplete.scss
Original file line number Diff line number Diff line change
@@ -1,59 +1,73 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */

/*
?Styling for shift autocomplete component
*/
.more-left-margin {
margin-left: -6px !important;
}

.autoSeparator {
flex: 1;
width: 90%;
background-color: $gray-400;
height: 1.25px;
display: flex;
align-self: center;
margin-top: 10px;
margin-bottom: 10px;
}
.listbox {
position: absolute;
padding: 10px 0;
margin: -5px 0 0 -2px;
z-index: 1;
list-style: none;
overflow: auto;
font-family: $font-family-primary;
font-size: $font-size-lg;
line-height: 175%;
text-align: left;
color: $primary;
background-color: $white;
font-weight: $font-weight-normal;
box-shadow: 0 4px 7px rgba(16, 32, 70, 0.2);
max-height: 500px;
border-radius: 7px;
min-width: 250px;
min-width: 260px;
z-index: 300;

& li {
clear: both;
min-height: 25px;
& > div {
display: flex;
margin-left: 0.6em;
flex: 1;
flex-direction: row;
flex-wrap: nowrap;
letter-spacing: 0.75px;
align-content: center;
justify-items: center;
justify-content: left;
&:hover {
font-style: italic;
font-weight: $font-weight-extra-bold;
cursor: pointer;
}
&[data-focus="true"] {
cursor: pointer;
}

.container {
display: block;
margin-left: 15px;

.colorSample {
width: 9px;
height: 9px;
border-radius: 50%;
float: left;
margin: 8.5px 20px 0 10px;
}

.optionLabel {
float: left;
clear: both;
}
> .optionLabel {
display: flex;
flex-direction: row;
flex-wrap: nowrap;
margin-right: 0.2em;
word-wrap: normal;
overflow-wrap: normal;
}
> .colorSamplee {
display: flex;
width: 9px;
height: 9px;
border-radius: 50%;
margin: 0 0;
align-self: center;
}
}
}
3 changes: 1 addition & 2 deletions src/assets/styles/styles/custom/_header.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
justify-content: space-around;
position: fixed;
top: 0;
z-index: 500;
//z-index: 1301;
z-index: 2;

#AssignmentIndIcon {
color: $header-text-color;
Expand Down
27 changes: 27 additions & 0 deletions src/components/app-error-boundary/app-error-boundary.component.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */

import React, { ReactNode, useCallback, useState } from "react";
import AppErrorModal from "../common-components/modal/app-error-modal/app-error.modal.component";
import * as Sentry from "@sentry/react";

interface AppErrorBoundaryOptions {
children: ReactNode;
}

export function AppErrorBoundary(props: AppErrorBoundaryOptions): JSX.Element {
const [open, setIsOpen] = useState(false);
const fallback = useCallback(
({ resetError }): JSX.Element => (
<AppErrorModal onClick={resetError} open={open} setOpen={setIsOpen} />
),
[open, setIsOpen]
);

const onError = useCallback((): void => {
setIsOpen(true);
}, [setIsOpen]);

return <Sentry.ErrorBoundary fallback={fallback} onError={onError} {...props} />;
}

This file was deleted.

Loading

0 comments on commit 7f56a2d

Please sign in to comment.