Skip to content

Commit 5518986

Browse files
fix unnecessary updates when the new end date was equal to the exising end date
1 parent d6dd958 commit 5518986

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

ui/src/utils/date.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,29 @@
1414
// KIND, either express or implied. See the License for the
1515
// specific language governing permissions and limitations
1616
// under the License.
17-
import dayjs from 'dayjs'
1817
import store from '@/store'
1918

19+
import dayjs from 'dayjs'
20+
import isToday from 'dayjs/plugin/isToday'
21+
22+
dayjs.extend(isToday)
23+
2024
export function parseDayJsObject ({ value, format }) {
25+
if (!value) {
26+
return null
27+
}
28+
2129
if (!format) {
2230
return value
2331
}
2432

2533
return value.format(format)
2634
}
2735

36+
export function isDayJsObjectToday (dayJsObject) {
37+
return dayJsObject.isToday()
38+
}
39+
2840
export function parseDateToDatePicker (value) {
2941
if (!value) {
3042
return null

ui/src/views/plugins/quota/EditQuotaTariff.vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,10 @@ export default {
125125
params.value = values.value
126126
}
127127
128-
if (values.endDate && this.resource.endDate !== values.endDate) {
129-
params.enddate = parseDayJsObject({ value: values.endDate, format: 'YYYY-MM-DD' })
128+
const resourceEndDate = this.resource.endDate?.split('T')[0]
129+
const parsedEndDate = parseDayJsObject({ value: values.endDate, format: 'YYYY-MM-DD' })
130+
if (parsedEndDate && resourceEndDate !== parsedEndDate) {
131+
params.enddate = parsedEndDate
130132
}
131133
132134
if (Object.keys(params).length === 1) {

0 commit comments

Comments
 (0)