34 |
{selected}
35 |
36 | {
40 | resetScroll();
41 | moveToFirst();
42 | }}
43 | disabled={!hasPreviousPage}
44 | />
45 | {
49 | resetScroll();
50 | movePrevious();
51 | }}
52 | disabled={!hasPreviousPage}
53 | />
54 | Page {currentPage}
55 | {
59 | resetScroll();
60 | moveNext();
61 | }}
62 | disabled={!hasNextPage}
63 | />
64 |
65 |
66 | );
67 | };
68 |
--------------------------------------------------------------------------------
/EditableTable/components/InputComponents/timeList.ts:
--------------------------------------------------------------------------------
1 | import { IComboBoxOption } from '@fluentui/react';
2 |
3 | export const timesList: IComboBoxOption[] = [
4 | { text: '12:00 AM', key: '00:00' },
5 | { text: '12:30 AM', key: '00:30' },
6 | { text: '1:00 AM', key: '01:00' },
7 | { text: '1:30 AM', key: '01:30' },
8 | { text: '2:00 AM', key: '02:00' },
9 | { text: '2:30 AM', key: '02:30' },
10 | { text: '3:00 AM', key: '03:00' },
11 | { text: '3:30 AM', key: '03:30' },
12 | { text: '4:00 AM', key: '04:00' },
13 | { text: '4:30 AM', key: '04:30' },
14 | { text: '5:00 AM', key: '05:00' },
15 | { text: '5:30 AM', key: '05:30' },
16 | { text: '6:00 AM', key: '06:00' },
17 | { text: '6:30 AM', key: '06:30' },
18 | { text: '7:00 AM', key: '07:00' },
19 | { text: '7:30 AM', key: '07:30' },
20 | { text: '8:00 AM', key: '08:00' },
21 | { text: '8:30 AM', key: '08:30' },
22 | { text: '9:00 AM', key: '09:00' },
23 | { text: '9:30 AM', key: '09:30' },
24 | { text: '10:00 AM', key: '10:00' },
25 | { text: '10:30 AM', key: '10:30' },
26 | { text: '11:00 AM', key: '11:00' },
27 | { text: '11:30 AM', key: '11:30' },
28 | { text: '12:00 PM', key: '12:00' },
29 | { text: '12:30 PM', key: '12:30' },
30 | { text: '1:00 PM', key: '13:00' },
31 | { text: '1:30 PM', key: '13:30' },
32 | { text: '2:00 PM', key: '14:00' },
33 | { text: '2:30 PM', key: '14:30' },
34 | { text: '3:00 PM', key: '15:00' },
35 | { text: '3:30 PM', key: '15:30' },
36 | { text: '4:00 PM', key: '16:00' },
37 | { text: '4:30 PM', key: '16:30' },
38 | { text: '5:00 PM', key: '17:00' },
39 | { text: '5:30 PM', key: '17:30' },
40 | { text: '6:00 PM', key: '18:00' },
41 | { text: '6:30 PM', key: '18:30' },
42 | { text: '7:00 PM', key: '19:00' },
43 | { text: '7:30 PM', key: '19:30' },
44 | { text: '8:00 PM', key: '20:00' },
45 | { text: '8:30 PM', key: '20:30' },
46 | { text: '9:00 PM', key: '21:00' },
47 | { text: '9:30 PM', key: '21:30' },
48 | { text: '10:00 PM', key: '22:00' },
49 | { text: '10:30 PM', key: '22:30' },
50 | { text: '11:00 PM', key: '23:00' },
51 | { text: '11:30 PM', key: '23:30' },
52 | ];
53 |
--------------------------------------------------------------------------------
/EditableTable/styles/DatasetStyles.css:
--------------------------------------------------------------------------------
1 | .appWrapper {
2 | position: relative;
3 | z-index: 0;
4 | }
5 |
6 | .container {
7 | width: 100%;
8 | position: relative;
9 | color:black;
10 | flex-wrap: wrap;
11 | display: inline;
12 | }
13 |
14 | .ms-DetailsList {
15 | z-index: 2;
16 | }
17 |
18 | .ms-DetailsHeader-cell{
19 | margin: 0px 4px;
20 | cursor: pointer;
21 | }
22 |
23 | .ms-DetailsRow-cell {
24 | padding: 0px;
25 | margin: 0px 4px;
26 | padding-top: 4px;
27 | overflow: visible;
28 | }
29 |
30 | .ms-DetailsRow-check {
31 | padding: 0px;
32 | margin-top: -4px;
33 | }
34 |
35 | @media screen and (max-width: 500px) {
36 | .ms-Button--commandBar{
37 | font-size: 11px;
38 | }
39 | }
40 |
41 | @media screen and (max-width: 350px) {
42 | .ms-Button--commandBar{
43 | font-size: 8px;
44 | }
45 | .ms-Button-textContainer{
46 | font-size: 10px;
47 | }
48 | }
49 |
50 | .noDataContainer {
51 | position: absolute;
52 | top: 66px;
53 | width: -webkit-fill-available;
54 | height: -webkit-fill-available;
55 | justify-content: center;
56 | }
57 |
58 | .nodata {
59 | margin : 50px;
60 | font-size : 14px;
61 | text-align: center;
62 | }
63 |
64 | .loading {
65 | display: block;
66 | position: absolute;
67 | width: -webkit-fill-available;
68 | height: -webkit-fill-available;
69 | align-content: center;
70 | text-align: center;
71 | top: 0;
72 | padding: 106px 469px;
73 | background-color: white;
74 | opacity: 80%;
75 | z-index: 10;
76 | }
77 |
78 | .ms-DetailsHeader-cellName {
79 | font-size: 12px;
80 | }
81 |
82 | .errorDiv {
83 | position: absolute;
84 | right: 20px;
85 | top: 11px;
86 | width: 16px;
87 | height: 16px;
88 | }
89 |
90 | .errorDiv[title] {
91 | border-color: rgba(248, 58, 58, 0.326);
92 | }
93 |
94 |
95 | .ms-DetailsList-headerWrapper {
96 | display: inline;
97 | }
98 | .ms-BasePicker-text::after {
99 | border: none;
100 | border-right: 1px solid black;
101 | }
102 |
103 | .ms-BasePicker-text:active {
104 | border: 2px solid rgb(0, 120, 212) !important;
105 | }
106 |
--------------------------------------------------------------------------------
/EditableTable/utils/dateTimeUtils.ts:
--------------------------------------------------------------------------------
1 | import { timesList } from '../components/InputComponents/timeList';
2 |
3 | export const getDateFormatWithHyphen = (date: Date | undefined) => {
4 | if (date === undefined) return '';
5 |
6 | const day = date.getDate() > 9 ? date.getDate() : `0${date.getDate()}`;
7 | const month = date.getMonth() + 1 > 9 ? `${date.getMonth() + 1}` : `0${date.getMonth() + 1}`;
8 |
9 | return `${date.getFullYear()}-${month}-${day}`;
10 | };
11 |
12 | export const setTimeForDate = (value: Date | undefined, time: string | undefined) => {
13 | if (time === undefined || value === undefined) return value;
14 |
15 | const hours = time.split(':');
16 | const newValue = value;
17 | newValue.setHours(parseFloat(hours[0]), parseFloat(hours[1]));
18 |
19 | return newValue;
20 | };
21 |
22 | export const formatTimeto12Hours = (date: Date | undefined): string => {
23 | if (date === undefined) return '';
24 |
25 | return date.toLocaleTimeString('en-US', {
26 | hour: 'numeric',
27 | minute: 'numeric',
28 | hour12: true,
29 | });
30 | };
31 |
32 | export const getTimeKeyFromDate = (date: Date) => {
33 | const hour = date.getHours() > 9
34 | ? date.getHours()
35 | : `0${date.getHours()}`;
36 |
37 | const minutes = date.getMinutes() > 9
38 | ? date.getMinutes()
39 | : `0${date.getMinutes()}`;
40 |
41 | const time = timesList.find(time => time.key === `${hour}:${minutes}`);
42 | return time === undefined ? `${hour}:${minutes}` : time.key;
43 | };
44 |
45 | export const getTimeKeyFromTime = (value: string) => {
46 | let key = undefined;
47 | const timeRegex = /^(0?[1-9]|1[0-2]):[0-5]\d(?:\s|)(?:AM|PM)$/i;
48 | if (timeRegex.test(value.toLowerCase().toString())) {
49 | const splitKey = value.match(/[a-zA-Z]+|[0-9]+/g);
50 | if (splitKey !== null) {
51 | const hour = splitKey[0] === '12' ? 0 : parseFloat(splitKey[0]);
52 | if (splitKey[2].toLowerCase() === 'pm') {
53 | key = `${hour + 12}:${splitKey[1]}`;
54 | }
55 | else if (hour < 10) {
56 | key = `0${hour}:${splitKey[1]}`;
57 | }
58 | else {
59 | key = `${hour}:${splitKey[1]}`;
60 | }
61 | }
62 | }
63 | return key;
64 | };
65 |
--------------------------------------------------------------------------------
/PCF-EditableTable.pcfproj:
--------------------------------------------------------------------------------
1 |
2 |