Skip to content

Commit

Permalink
Remove redundant code, semaphores and todos (#29079)
Browse files Browse the repository at this point in the history
Co-authored-by: Vladimir Bushmanov <vladimir.bushmanov@devexpress.com>
  • Loading branch information
Ambrozy and Vladimir Bushmanov authored Feb 20, 2025
1 parent 8c8cbd1 commit 60f5de4
Show file tree
Hide file tree
Showing 25 changed files with 29 additions and 122 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { extend } from '@js/core/utils/extend';
import Form from '@js/ui/form';
import { current, isFluent } from '@js/ui/themes';
import { ExpressionUtils } from '@ts/scheduler/m_expression_utils';
import { Semaphore } from '@ts/scheduler/r1/semaphore/index';

import { createAppointmentAdapter } from '../m_appointment_adapter';
import timeZoneUtils from '../m_utils_time_zone';
Expand Down Expand Up @@ -63,15 +62,12 @@ export class AppointmentForm {

form: any;

// TODO: Why we need the "semaphore" in the sync code?
// We should research it and delete it if redundant
semaphore: Semaphore;
// NOTE: flag to prevent double value set during form updating
private isFormUpdating = false;

constructor(scheduler) {
this.scheduler = scheduler;
this.form = null;

this.semaphore = new Semaphore();
}

get dxForm() {
Expand Down Expand Up @@ -194,7 +190,7 @@ export class AppointmentForm {
const dateEditor = this.form.getEditor(dateExpr);
const dateValue = dateSerialization.deserializeDate(dateEditor.option('value'));

if (this.semaphore.isFree() && dateValue && value && isNeedCorrect(dateValue, value)) {
if (!this.isFormUpdating && dateValue && value && isNeedCorrect(dateValue, value)) {
const duration = previousValue ? dateValue.getTime() - previousValue.getTime() : 0;
dateEditor.option('value', new Date(value.getTime() + duration));
}
Expand Down Expand Up @@ -337,7 +333,7 @@ export class AppointmentForm {
const endDateEditor = this.form.getEditor(dataExprs.endDateExpr);
const startDate = dateSerialization.deserializeDate(startDateEditor.option('value'));

if (this.semaphore.isFree() && startDate) {
if (!this.isFormUpdating && startDate) {
if (value) {
const allDayStartDate = dateUtils.trimTime(startDate);
startDateEditor.option('value', new Date(allDayStartDate));
Expand Down Expand Up @@ -459,8 +455,7 @@ export class AppointmentForm {
}

updateFormData(formData) {
this.semaphore.take();

this.isFormUpdating = true;
this.form.option('formData', formData);

const dataAccessors = this.scheduler.getDataAccessors();
Expand All @@ -479,8 +474,7 @@ export class AppointmentForm {
this.updateRecurrenceEditorStartDate(startDate, expr.recurrenceRuleExpr);

this.setEditorsType(allDay);

this.semaphore.release();
this.isFormUpdating = false;
}

private createDateBoxEditor(dataField, colSpan, firstDayOfWeek, label, cssClass, onValueChanged) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,11 +255,6 @@ export class AppointmentFilterBaseStrategy {
}]];
}

// TODO get rid of wrapper
_createAppointmentFilter(filterOptions) {
return this._createCombinedFilter(filterOptions);
}

_filterAppointmentByResources(appointment, resources) {
const checkAppointmentResourceValues = (resourceName, resourceIndex) => {
const resourceGetter = this.dataAccessors.resources.getter[resourceName];
Expand Down Expand Up @@ -346,7 +341,7 @@ export class AppointmentFilterBaseStrategy {
}

filterPreparedItems(filterOptions, preparedItems) {
const combinedFilter = this._createAppointmentFilter(filterOptions);
const combinedFilter = this._createCombinedFilter(filterOptions);

// @ts-expect-error
return query(preparedItems)
Expand Down Expand Up @@ -451,7 +446,7 @@ export class AppointmentFilterVirtualStrategy extends AppointmentFilterBaseStrat
filterOptions.forEach((option) => {
combinedFilters.length && combinedFilters.push('or');

const filter = this._createAppointmentFilter(option);
const filter = this._createCombinedFilter(option);

combinedFilters.push(filter);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ class SchedulerAppointments extends CollectionWidget {
this._virtualAppointments = {};
}

// TODO: remove when Collection moved to TS
// eslint-disable-next-line @typescript-eslint/no-unused-vars
option(optionName?: string, value?: any) {
return super.option(...arguments);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export class AppointmentViewModelGenerator {
this.initRenderingStrategy(options);

const renderingStrategy = this.getRenderingStrategy();
const positionMap = renderingStrategy.createTaskPositionMap(appointments); // TODO - appointments are mutated inside!
const positionMap = renderingStrategy.createTaskPositionMap(appointments); // appointments are mutated inside!
const shiftedViewModel = this.postProcess(appointments, positionMap);
const viewModel = this.unshiftViewModelAppointmentsByViewOffset(shiftedViewModel, viewOffset);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,7 @@ class AgendaRenderingStrategy extends BaseRenderingStrategy {
replaceWrongEndDate(adapter, startDate, endDate, this.cellDuration, this.dataAccessors);
}

// TODO: get rid of an extra 'needClearSettings' argument
calculateRows(appointments, agendaDuration, currentDate, needClearSettings?) {
calculateRows(appointments, agendaDuration, currentDate) {
this._rows = [];
currentDate = dateUtils.trimTime(new Date(currentDate));

Expand All @@ -218,8 +217,6 @@ class AgendaRenderingStrategy extends BaseRenderingStrategy {

this.replaceWrongAppointmentEndDate(appointment, startDate, endDate);

needClearSettings && delete appointment.settings;

const result = this.instance.getAppointmentsInstance()._processRecurrenceAppointment(appointment, index, false);
appts.parts = appts.parts.concat(result.parts);
appts.indexes = appts.indexes.concat(result.indexes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ class AppointmentAdapter {

source(serializeDate = false) {
if (serializeDate) {
// TODO: hack for use dateSerializationFormat
// hack for use dateSerializationFormat
const clonedAdapter = this.clone();
clonedAdapter.startDate = this.startDate;
clonedAdapter.endDate = this.endDate;
Expand Down
3 changes: 1 addition & 2 deletions packages/devextreme/js/__internal/scheduler/m_loading.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ export function show(options) {
}

export function hide() {
// todo: hot fix for case without viewport

// hot fix for case without viewport
if (!loading) {
// @ts-expect-error
return new Deferred().resolve();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const MONTH_OF_YEAR = 'dx-recurrence-selectbox-month-of-year';

const recurrentEditorNumberBoxWidth = 70;
const recurrentEditorSelectBoxWidth = 120;
const defaultRecurrenceTypeIndex = 1; // TODO default daily recurrence
const defaultRecurrenceTypeIndex = 1; // default daily recurrence

const frequenciesMessages = [
/* {
Expand Down
11 changes: 3 additions & 8 deletions packages/devextreme/js/__internal/scheduler/m_scheduler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1525,7 +1525,7 @@ class Scheduler extends Widget<any> {
this._validateKeyFieldIfAgendaExist();
}

_isDataSourceLoaded() { // TODO
_isDataSourceLoaded() {
return this._dataSource && this._dataSource.isLoaded();
}

Expand Down Expand Up @@ -1637,17 +1637,13 @@ class Scheduler extends Widget<any> {
return this._getCurrentViewOption('cellDuration');
}

_getCurrentViewType() { // TODO get rid of mapping
return this.currentViewType;
}

_renderWorkSpace(groups) {
this._readyToRenderAppointments && this._toggleSmallClass();
const $workSpace = $('<div>').appendTo(this._mainContainer);

const countConfig = this._getViewCountConfig();

const workSpaceComponent = VIEWS_CONFIG[this._getCurrentViewType()].workSpace;
const workSpaceComponent = VIEWS_CONFIG[this.currentViewType].workSpace;
const workSpaceConfig = this._workSpaceConfig(groups, countConfig);
// @ts-expect-error
this._workSpace = this._createComponent($workSpace, workSpaceComponent, workSpaceConfig);
Expand Down Expand Up @@ -2236,7 +2232,7 @@ class Scheduler extends Widget<any> {
}

/// #DEBUG
getAppointmentDetailsForm() { // TODO for tests
getAppointmentDetailsForm() { // for tests
return this._appointmentForm.form;
}
/// #ENDDEBUG
Expand Down Expand Up @@ -2647,7 +2643,6 @@ class Scheduler extends Widget<any> {
private validateOptions(): void {
const currentViewOptions = {
...this.option(),
// TODO: Check it before 24.1 release
// NOTE: We override this.option values here
// because the old validation logic checked only current view options.
// Changing it and validate all views configuration will be a BC.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ const subscribes = {
this.timeZoneCalculator,
);

// TODO pull out time zone converting from appointment adapter for knockout(T947938)
// pull out time zone converting from appointment adapter for knockout(T947938)
const startDate = this.timeZoneCalculator.createDate(targetedAdapter.startDate, { path: 'toGrid' });
const endDate = this.timeZoneCalculator.createDate(targetedAdapter.endDate, { path: 'toGrid' });

Expand Down
1 change: 0 additions & 1 deletion packages/devextreme/js/__internal/scheduler/m_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ export const utils = {
component = widget._createComponent(container, componentClass, viewModel);
widget[componentName] = component;
} else {
// TODO: this is a workaround for setTablesSizes. Remove after CSS refactoring
const $element = component.$element();
const elementStyle = $element.get(0).style;
const { height } = elementStyle;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ const isEqualLocalTimeZoneByDeclaration = (timeZoneName: string, date: Date): bo
return false;
};

// TODO: Getting two dates in january or june is the standard mechanism for determining that an offset has occurred.
// Getting two dates in january or june is the standard mechanism for determining that an offset has occurred.
const getExtremeDates = () => {
const nowDate = new Date(Date.now());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ export interface GlobalErrorHandler {
throwError: (errorCode: string) => void;
}

// TODO: This export just a workaround for SystemJS issue
// This export just a workaround for SystemJS issue
// with ts files that contains only type definitions.
export const REDUNDANT_EXPORT = undefined;
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ export type SchedulerValidatorNames = 'startDayHour'
| 'cellDuration'
| 'cellDurationAndVisibleInterval';

// TODO: This export just a workaround for SystemJS issue
// This export just a workaround for SystemJS issue
// with ts files that contains only type definitions.
export const REDUNDANT_EXPORT = undefined;
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export interface DateHeaderCellProps extends CellBaseProps {
colSpan: number;
isWeekDayCell: boolean;
splitText: boolean;
// TODO: this is a workaround for https://github.com/DevExpress/devextreme-renovation/issues/574
// this is a workaround for https://github.com/DevExpress/devextreme-renovation/issues/574
isTimeCellTemplate: boolean;
timeCellTemplate?: JSXTemplate<DateTimeCellTemplateProps>;
dateCellTemplate?: JSXTemplate<DateTimeCellTemplateProps>;
Expand Down Expand Up @@ -66,7 +66,7 @@ export class DateHeaderCell extends BaseInfernoComponent<DateHeaderCellProps> {
const DateCellTemplateComponent = getTemplate(dateCellTemplate);

const children = useTemplate ? (
// TODO: this is a workaround for https://github.com/DevExpress/devextreme-renovation/issues/574
// this is a workaround for https://github.com/DevExpress/devextreme-renovation/issues/574
<>
{isTimeCellTemplate && TimeCellTemplateComponent
&& TimeCellTemplateComponent({
Expand Down

This file was deleted.

23 changes: 0 additions & 23 deletions packages/devextreme/js/__internal/scheduler/r1/semaphore/index.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/devextreme/js/__internal/scheduler/r1/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export interface AppointmentFilter {
export interface CustomLoadDataType { data: Appointment[] }

export interface AppointmentGeometry {
empty: boolean; // TODO
empty: boolean;
left: number;
top: number;
width: number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ export const getPathToLeaf = (leafIndex, groups) => {
return makeBranch(leaf).reverse();
};

// TODO rework
export const getCellGroups = (groupIndex, groups) => {
const result: any = [];

Expand Down Expand Up @@ -499,7 +498,7 @@ const getTransformedResourceData = (resource, data) => {
text: displayGetter(item),
};

if (item.color) { // TODO for passed tests
if (item.color) { // for tests
result.color = item.color;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export class DesktopTooltipStrategy extends TooltipStrategyBase {
_createListOption(target, dataList) {
// @ts-expect-error
const result: any = super._createListOption(target, dataList);
// TODO:T724287 this condition is not covered by tests, because touch variable cannot be overridden.
// T724287 this condition is not covered by tests, because touch variable cannot be overridden.
// In the future, it is necessary to cover the tests
result.showScrollbar = supportUtils.touch ? 'always' : 'onHover';
return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,6 @@ class GroupStrategyBase {

let result = lastGroupRow[0].top + lastGroupRow[0].height;

// TODO remove while refactoring dual calculcations.
// Should decrease allDayPanel amount due to the dual calculation corrections.
if (isGroupedAllDayPanel) {
result -= (groupIndex + 1) * this._getAllDayHeight(showAllDayPanel);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,6 @@ class SchedulerAgenda extends WorkSpace {
}

_getGroupRowHeight(groupRows) {
// TODO: hotfix
if (!groupRows) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ export class VirtualScrollingDispatcher {
let cellWidth = this.options.getCellWidth();
const minCellWidth = this.options.getCellMinWidth();

// TODO: Remove this after CSS refactoring
if (!cellWidth || cellWidth < minCellWidth) {
cellWidth = minCellWidth;
}
Expand Down
Loading

0 comments on commit 60f5de4

Please sign in to comment.