utility-types#MutableKeys TypeScript Examples
The following examples show how to use
utility-types#MutableKeys.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: attendance.ts From orangehrm-os-mobile with GNU General Public License v3.0 | 6 votes |
calculateWorkData = (
graphRecordsInputData: GraphRecordsObject,
startDayIndex: number,
) => {
const workGraphData: GraphDataPoint[] = [];
const daysInUppercase = getWeekdayOrder(startDayIndex, 'dddd');
const days = daysInUppercase.map((day: string) => {
return day.toLocaleLowerCase();
});
days.forEach((day) => {
const key = <MutableKeys<WorkSummaryObject>>day;
const hours = graphRecordsInputData.workSummary[key].workHours;
const data: GraphDataPoint = {
x: dayMapper[key],
y: parseFloat(hours),
};
workGraphData.push(data);
});
return workGraphData;
}
Example #2
Source File: attendance.ts From orangehrm-os-mobile with GNU General Public License v3.0 | 6 votes |
calculateDateSelectorData = (
workSummaryObject?: WorkSummaryObject,
startDayIndex?: number,
) => {
if (workSummaryObject !== undefined && startDayIndex !== undefined) {
const selectedWeek: DaySelectorSingleDay[] = [];
for (let index = startDayIndex; index < startDayIndex + 7; index++) {
const date = getWeekDayFromIndex(index);
const day = convertDateObjectToStringFormat(
date,
'dddd',
).toLocaleLowerCase();
const key = <MutableKeys<WorkSummaryObject>>day;
const hours = workSummaryObject[key].workHours;
const daySelectorSingleDay: DaySelectorSingleDay = {
date: date,
duration: getDurationFromHours(parseFloat(hours)),
};
selectedWeek.push(daySelectorSingleDay);
}
return selectedWeek;
} else {
return [];
}
}
Example #3
Source File: attendance.ts From orangehrm-os-mobile with GNU General Public License v3.0 | 6 votes |
getWorkWeekResultOfTheSelectedDate = (
workweek?: WorkWeek,
selectedDay?: moment.Moment,
) => {
if (workweek !== undefined && selectedDay !== undefined) {
const days = ['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'];
let hours;
days.forEach((day) => {
if (selectedDay.format('ddd').toLocaleLowerCase() === day) {
const key = <MutableKeys<WorkWeek>>day;
hours = workweek[key];
}
});
return hours;
} else {
return '-1';
}
}
Example #4
Source File: instance-check.ts From orangehrm-os-mobile with GNU General Public License v3.0 | 6 votes |
checkRemovedEndpoints = (openApiDefinition: any): void => {
const paths = getOpenApiDefinitionPaths(openApiDefinition);
Object.keys(REQUIRED_ENDPOINTS).forEach((key) => {
const path = <MutableKeys<typeof REQUIRED_ENDPOINTS>>key;
REQUIRED_ENDPOINTS[path].forEach((operation) => {
const exist = paths[path]?.hasOwnProperty(operation);
if (!exist) {
throw new InstanceCheckError('Please Update the Application.');
}
});
});
}
Example #5
Source File: instance-check.ts From orangehrm-os-mobile with GNU General Public License v3.0 | 6 votes |
checkDeprecatedEndpoints = (openApiDefinition: any): boolean => {
if (openApiDefinition.paths && openApiDefinition.info['x-base-path']) {
const paths = getOpenApiDefinitionPaths(openApiDefinition);
for (const key of Object.keys(REQUIRED_ENDPOINTS)) {
const path = <MutableKeys<typeof REQUIRED_ENDPOINTS>>key;
for (const operation of REQUIRED_ENDPOINTS[path]) {
const deprecated = paths[path]?.[operation]?.deprecated;
if (deprecated === true) {
return true;
}
}
}
return false;
}
throw new InstanceCheckError('Incompatible OpenAPI version.');
}
Example #6
Source File: attendance.ts From orangehrm-os-mobile with GNU General Public License v3.0 | 5 votes |
calculateGraphData = (
leaveTypesInputData: GraphRecordsObject,
startDayIndex: number,
) => {
const leaveGraphData: LeaveTypeGraphData[] = [];
const leaveTypeIds: string[] = [];
leaveTypesInputData.totalLeaveTypeHours.forEach((leave) => {
leaveTypeIds.push(leave.typeId);
});
leaveTypeIds.forEach((id) => {
const data: GraphDataPoint[] = [];
const colour: string = getLeaveColourById(id);
const daysInUppercase = getWeekdayOrder(startDayIndex, 'dddd');
const days = daysInUppercase.map((day: string) => {
return day.toLocaleLowerCase();
});
days.forEach((day) => {
const key = <MutableKeys<WorkSummaryObject>>day;
const filteredLeaves = leaveTypesInputData.workSummary[key].leave.filter(
(leave) => {
return leave.typeId === id;
},
);
let singleData: GraphDataPoint;
if (filteredLeaves.length === 0) {
singleData = {
x: dayMapper[key],
y: 0,
};
} else {
singleData = {
x: dayMapper[key],
y: parseFloat(filteredLeaves[0].hours),
};
}
data.push(singleData);
});
const leaveTypeGraphData: LeaveTypeGraphData = {
id: id,
colour: colour,
data: data,
};
leaveGraphData.push(leaveTypeGraphData);
});
return leaveGraphData;
}