-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Client Count Calendar widget updates #13777
Changes from 4 commits
97174c6
61dbf73
1bcc475
8e1d1c2
7c3a556
ee59c95
ced1b71
9d839c2
9665132
4e232cc
f0a1dda
26c52b3
d4ef54f
b733242
9a9f8c5
8d16719
c88579d
d9b7b99
ab382b1
54d398e
43de131
ad592fb
de16cac
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,21 +39,21 @@ export default class Dashboard extends Component { | |
@tracked isEditStartMonthOpen = false; | ||
@tracked responseRangeDiffMessage = null; | ||
@tracked startTimeRequested = null; | ||
@tracked startTimeFromResponse = this.args.model.startTimeFromLicense; // ex: "3,2021" | ||
@tracked startTimeFromResponse = this.args.model.startTimeFromLicense; // ex: ['2021', 3] is April 2021 (0 indexed) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. great comments, thank you for the example! |
||
@tracked endTimeFromResponse = this.args.model.endTimeFromLicense; | ||
@tracked startMonth = null; | ||
@tracked startYear = null; | ||
@tracked selectedNamespace = null; | ||
// @tracked selectedNamespace = 'namespacelonglonglong4/'; // for testing namespace selection view | ||
|
||
get startTimeDisplay() { | ||
// changes 3,2021 to March, 2021 | ||
if (!this.startTimeFromResponse) { | ||
// otherwise will return date of new Date(null) | ||
return null; | ||
} | ||
let month = Number(this.startTimeFromResponse.split(',')[0]) - 1; | ||
let year = this.startTimeFromResponse.split(',')[1]; | ||
// this.startTimeFromResponse = ['2021', 2] is March 2021 | ||
Monkeychip marked this conversation as resolved.
Show resolved
Hide resolved
|
||
let month = this.startTimeFromResponse[1]; | ||
let year = this.startTimeFromResponse[0]; | ||
return `${this.arrayOfMonths[month]} ${year}`; | ||
} | ||
|
||
|
@@ -63,8 +63,8 @@ export default class Dashboard extends Component { | |
// otherwise will return date of new Date(null) | ||
return null; | ||
} | ||
let month = Number(this.endTimeFromResponse.split(',')[0]) - 1; | ||
let year = this.endTimeFromResponse.split(',')[1]; | ||
let month = this.endTimeFromResponse[1]; | ||
let year = this.endTimeFromResponse[0]; | ||
return `${this.arrayOfMonths[month]} ${year}`; | ||
} | ||
|
||
|
@@ -106,6 +106,22 @@ export default class Dashboard extends Component { | |
} | ||
return this.args.model.activity.responseTimestamp; | ||
} | ||
// HELPERS | ||
areArraysTheSame(a1, a2) { | ||
return ( | ||
a1 === a2 || | ||
(a1 !== null && | ||
a2 !== null && | ||
a1.length === a2.length && | ||
a1 | ||
.map(function (val, idx) { | ||
return val === a2[idx]; | ||
}) | ||
.reduce(function (prev, cur) { | ||
return prev && cur; | ||
}, true)) | ||
); | ||
} | ||
|
||
// ACTIONS | ||
@action | ||
|
@@ -121,14 +137,14 @@ export default class Dashboard extends Component { | |
// clicked "Edit" Billing start month in Dashboard which opens a modal. | ||
if (dateType === 'startTime') { | ||
let monthIndex = this.arrayOfMonths.indexOf(month); | ||
this.startTimeRequested = `${monthIndex + 1},${year}`; // "1, 2021" | ||
this.startTimeRequested = [year.toString(), monthIndex]; // ['2021', 0] (e.g. January 2021) // TODO CHANGE TO ARRAY | ||
this.endTimeRequested = null; | ||
} | ||
// clicked "Custom End Month" from the calendar-widget | ||
if (dateType === 'endTime') { | ||
// use the currently selected startTime for your startTimeRequested. | ||
this.startTimeRequested = this.startTimeFromResponse; | ||
this.endTimeRequested = `${month},${year}`; // "1, 2021" | ||
this.endTimeRequested = [year.toString(), month]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. endTime and startTime come in a little different. One comes in as a month name (startTime) whereas endTime comes in as an index because it's a calendar of months instead of a list. I'll add a comment in the code. |
||
} | ||
|
||
try { | ||
|
@@ -140,10 +156,12 @@ export default class Dashboard extends Component { | |
// this.endTime will be null and use this to show EmptyState message on the template. | ||
return; | ||
} | ||
|
||
// note: this.startTimeDisplay (at getter) is updated by this.startTimeFromResponse | ||
this.startTimeFromResponse = response.formattedStartTime; | ||
this.endTimeFromResponse = response.formattedEndTime; | ||
if (this.startTimeRequested !== this.startTimeFromResponse) { | ||
// compare if the response and what you requested are the same. If they are not throw a warning. | ||
// this only gets triggered if the data was returned, which does not happen if the user selects a startTime after for which we have data. That's an adapter error and is captured differently. | ||
if (!this.areArraysTheSame(this.startTimeFromResponse, this.startTimeRequested)) { | ||
this.responseRangeDiffMessage = `You requested data from ${month} ${year}. We only have data from ${this.startTimeDisplay}, and that is what is being shown here.`; | ||
} else { | ||
this.responseRangeDiffMessage = null; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,3 @@ | ||
.has-margin-top { | ||
margin-top: $spacing-s; | ||
} | ||
.alert-banner-message-body { | ||
border: 0; | ||
margin-top: $spacing-xxs; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
made a ticket for this comment.