Skip to content

Commit

Permalink
[FIX] sap.m.SinglePlanningCalendarView: update JSDocs
Browse files Browse the repository at this point in the history
Issue: The method calculateStartDate in SinglePlanningCalendarView is
abstract and doesn't specify the return type in the JS Doc, which causes
errors in TypeScript.

Solution: Update the method's documentation with the expected return
type. Also update the parameter and return types in the other views to
be more specific. Also update return types for other methods and change
logging to throw error since methods are abstract.

Fixes: #4045

SNOW: DINC0144944
Change-Id: I78d8271380129caf398245df0716aac7d8a7aa73
  • Loading branch information
didip1000 committed May 21, 2024
1 parent ee05b0b commit c6b49ae
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 29 deletions.
12 changes: 6 additions & 6 deletions src/sap.m/src/sap/m/SinglePlanningCalendarDayView.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function (library, SinglePlanningCalendarView) {
/**
* Returns the number of columns to be displayed in the grid of the <code>sap.m.SinglePlanningCalendar</code>.
*
* @return {int} the number of columns to be displayed
* @returns {int} the number of columns to be displayed
* @override
* @public
*/
Expand All @@ -54,7 +54,7 @@ function (library, SinglePlanningCalendarView) {
* Should return a number of entities until the next/previous startDate of the
* <code>sap.m.SinglePlanningCalendar</code> after navigating forward or backwards.
*
* @return {int} the number of entities to be skipped by scrolling
* @returns {int} the number of entities to be skipped by scrolling
* @override
* @public
*/
Expand All @@ -66,13 +66,13 @@ function (library, SinglePlanningCalendarView) {
* Calculates the startDate which will be displayed in the <code>sap.m.SinglePlanningCalendar</code> based
* on a given date.
*
* @param {object} oStartDate the given date
* @return {object} the startDate of the view
* @param {Date|module:sap/ui/core/date/UI5Date} oDate The given date
* @returns {Date|module:sap/ui/core/date/UI5Date} The startDate of the view
* @override
* @public
*/
SinglePlanningCalendarDayView.prototype.calculateStartDate = function (oStartDate) {
return oStartDate;
SinglePlanningCalendarDayView.prototype.calculateStartDate = function (oDate) {
return oDate;
};

return SinglePlanningCalendarDayView;
Expand Down
10 changes: 5 additions & 5 deletions src/sap.m/src/sap/m/SinglePlanningCalendarMonthView.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ sap.ui.define([
*
* @param {object} oStartDate The current start date
* @param {int} iOffset The number of pages to scroll, negative means backwards
* @return {int} The number of entities to be skipped by scrolling
* @returns {int} The number of entities to be skipped by scrolling
* @override
* @public
*/
Expand All @@ -74,13 +74,13 @@ sap.ui.define([
* Calculates the <code>startDate</code> displayed in the <code>sap.m.SinglePlanningCalendar</code> based
* on a given date.
*
* @param {object} oStartDate The given date
* @return {object} The startDate of the view
* @param {Date|module:sap/ui/core/date/UI5Date} oDate The given date
* @returns {Date|module:sap/ui/core/date/UI5Date} The startDate of the view
* @override
* @public
*/
SinglePlanningCalendarMonthView.prototype.calculateStartDate = function(oStartDate) {
var oReturnDate = CalendarUtils.getFirstDateOfMonth(CalendarUtils._createUTCDate(oStartDate, true)).getJSDate();
SinglePlanningCalendarMonthView.prototype.calculateStartDate = function(oDate) {
var oReturnDate = CalendarUtils.getFirstDateOfMonth(CalendarUtils._createUTCDate(oDate, true)).getJSDate();
return CalendarUtils._createLocalDate(oReturnDate, true);
};

Expand Down
11 changes: 7 additions & 4 deletions src/sap.m/src/sap/m/SinglePlanningCalendarView.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,12 @@ function (library, Log, Element) {
/**
* Should return the number of columns to be displayed in the grid of the <code>sap.m.SinglePlanningCalendar</code>.
*
* @returns {int} the number of columns to be displayed
* @public
* @abstract
*/
SinglePlanningCalendarView.prototype.getEntityCount = function () {
Log.warning("This method should be implemented in one of the inherited classes.", this);
throw new Error("This method should be implemented in one of the inherited classes.");
};

/**
Expand All @@ -87,23 +88,25 @@ function (library, Log, Element) {
* pressing the forward button inside the work week view, the next startDate of a work week will be 7 entities
* (days) away from the current one.
*
* @returns {int} the number of entities to be skipped by scrolling
* @public
* @abstract
*/
SinglePlanningCalendarView.prototype.getScrollEntityCount = function () {
Log.warning("This method should be implemented in one of the inherited classes.", this);
throw new Error("This method should be implemented in one of the inherited classes.");
};

/**
* Should calculate the startDate which will be displayed in the <code>sap.m.SinglePlanningCalendar</code>
* based on a given date.
*
* @param {Date|module:sap/ui/core/date/UI5Date} oDate A date instance
* @param {Date|module:sap/ui/core/date/UI5Date} oDate The given date
* @returns {Date|module:sap/ui/core/date/UI5Date} The startDate of the view
* @public
* @abstract
*/
SinglePlanningCalendarView.prototype.calculateStartDate = function (oDate) {
Log.warning("This method should be implemented in one of the inherited classes.", this);
throw new Error("This method should be implemented in one of the inherited classes.");
};

return SinglePlanningCalendarView;
Expand Down
14 changes: 7 additions & 7 deletions src/sap.m/src/sap/m/SinglePlanningCalendarWeekView.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function (library, SinglePlanningCalendarView, Formatting, LocaleData, CalendarD
* Returns after how much entities is the next/previous startDate of the <code>sap.m.SinglePlanningCalendar</code> after
* navigating forward or backwards.
*
* @return {int} the number of entities to be skipped by scrolling
* @returns {int} the number of entities to be skipped by scrolling
* @override
* @public
*/
Expand All @@ -60,7 +60,7 @@ function (library, SinglePlanningCalendarView, Formatting, LocaleData, CalendarD
* Should return a number of entities until the next/previous startDate of the
* <code>sap.m.SinglePlanningCalendar</code> after navigating forward or backwards.
*
* @return {int} the number of entities to be skipped by scrolling
* @returns {int} the number of entities to be skipped by scrolling
*/
SinglePlanningCalendarWeekView.prototype.getScrollEntityCount = function () {
return 7;
Expand All @@ -70,12 +70,12 @@ function (library, SinglePlanningCalendarView, Formatting, LocaleData, CalendarD
* Calculates the startDate which will be displayed in the <code>sap.m.SinglePlanningCalendar</code> based
* on a given date.
*
* @param {object} oStartDate the given date
* @return {object} the startDate of the view
* @param {Date|module:sap/ui/core/date/UI5Date} oDate The given date
* @returns {Date|module:sap/ui/core/date/UI5Date} The startDate of the view
* @override
* @public
*/
SinglePlanningCalendarWeekView.prototype.calculateStartDate = function (oStartDate) {
SinglePlanningCalendarWeekView.prototype.calculateStartDate = function (oDate) {

var sLocale = new Locale(Formatting.getLanguageTag()).toString();

Expand All @@ -92,9 +92,9 @@ function (library, SinglePlanningCalendarView, Formatting, LocaleData, CalendarD
}
}

oStartDate.setDate(oStartDate.getDate() - oStartDate.getDay() + iFirstDayOfWeek);
oDate.setDate(oDate.getDate() - oDate.getDay() + iFirstDayOfWeek);
return CalendarUtils
._getFirstDateOfWeek(CalendarDate.fromLocalJSDate(oStartDate), {
._getFirstDateOfWeek(CalendarDate.fromLocalJSDate(oDate), {
firstDayOfWeek: iFirstDayOfWeek,
minimalDaysInFirstWeek: oLocaleData.getMinimalDaysInFirstWeek()
})
Expand Down
14 changes: 7 additions & 7 deletions src/sap.m/src/sap/m/SinglePlanningCalendarWorkWeekView.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function(library, SinglePlanningCalendarView, Formatting, Locale, CalendarDate,
/**
* Returns the number of columns to be displayed in the grid of the <code>sap.m.SinglePlanningCalendar</code>.
*
* @return {int} the number of columns to be displayed
* @returns {int} the number of columns to be displayed
* @override
* @public
*/
Expand All @@ -59,7 +59,7 @@ function(library, SinglePlanningCalendarView, Formatting, Locale, CalendarDate,
* Should return a number of entities until the next/previous startDate of the
* <code>sap.m.SinglePlanningCalendar</code> after navigating forward or backwards.
*
* @return {int} the number of entities to be skipped by scrolling
* @returns {int} the number of entities to be skipped by scrolling
* @override
* @public
*/
Expand All @@ -71,13 +71,13 @@ function(library, SinglePlanningCalendarView, Formatting, Locale, CalendarDate,
* Calculates the startDate which will be displayed in the <code>sap.m.SinglePlanningCalendar</code> based
* on a given date.
*
* @param {object} oStartDate the given date
* @return {object} the startDate of the view
* @param {Date|module:sap/ui/core/date/UI5Date} oDate The given date
* @returns {Date|module:sap/ui/core/date/UI5Date} The startDate of the view
* @override
* @public
*/
SinglePlanningCalendarWorkWeekView.prototype.calculateStartDate = function (oStartDate) {
var oCalDate = CalendarDate.fromLocalJSDate(oStartDate),
SinglePlanningCalendarWorkWeekView.prototype.calculateStartDate = function (oDate) {
var oCalDate = CalendarDate.fromLocalJSDate(oDate),
oCalFirstDateOfWeek = CalendarUtils._getFirstDateOfWeek(oCalDate),
oLocaleData = this._getFormatSettingsLocaleData();

Expand All @@ -91,7 +91,7 @@ function(library, SinglePlanningCalendarView, Formatting, Locale, CalendarDate,
/**
* Returns local data about the current locale.
*
* @return {LocaleData} the local data
* @returns {LocaleData} the local data
* @private
*/
SinglePlanningCalendarWorkWeekView.prototype._getFormatSettingsLocaleData = function () {
Expand Down

0 comments on commit c6b49ae

Please sign in to comment.