Use NCInputDateField in ShareDetailsPage
authorClaudio Cambra <claudio.cambra@nextcloud.com>
Tue, 8 Aug 2023 07:08:12 +0000 (15:08 +0800)
committerbackportbot-nextcloud[bot] <backportbot-nextcloud[bot]@users.noreply.github.com>
Wed, 13 Sep 2023 08:47:54 +0000 (08:47 +0000)
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
src/gui/filedetails/ShareDetailsPage.qml

index 380fd114262a8924eb2703b596f4f8117dad47c3..c09f42abd6dc24124ca303efacb53955992f309c 100644 (file)
@@ -64,7 +64,7 @@ Page {
     readonly property string passwordPlaceholder: "●●●●●●●●●●"
 
     readonly property var expireDate: shareModelData.expireDate // Don't use int as we are limited
-    readonly property var maximumExpireDate: shareModelData.enforcedMaximumExpireDate
+    readonly property var maximumExpireDate: shareModelData.enforcedMaximumExpireDate // msecs epoch
 
     readonly property string linkShareLabel: shareModelData.linkShareLabel ?? ""
 
@@ -127,7 +127,7 @@ Page {
         //
         // So to ensure that the text of the spin box is correctly updated, force an update of the
         // contents of the expire date text field.
-        expireDateSpinBox.updateText();
+        expireDateField.updateText();
         waitingForExpireDateChange = false;
     }
 
@@ -734,26 +734,29 @@ Page {
                 NCInputDateField {
                     id: expireDateField
 
-                    date: root.expireDate
-                    onDateChanged: {
-                        const value = valueFromText(text, expireDateSpinBox.locale);
-                        root.setExpireDate(value * dayInMSecs);
-                        root.waitingForExpireDateChange = true;
-                    }
+                    Layout.fillWidth: true
+                    height: visible ? implicitHeight : 0
 
-                    maximumDate: root.maximumExpireDate
-                    minimumDate: {
+                    dateInMs: root.expireDate
+                    maximumDateMs: root.maximumExpireDate
+                    minimumDateMs: {
                         const currentDate = new Date();
+                        const currentYear = currentDate.getFullYear();
+                        const currentMonth = currentDate.getMonth();
+                        const currentMonthDay = currentDate.getDate();
                         // Start of day at 00:00:0000 UTC
-                        return new Date(Date.UTC(currentDate.getFullYear(),
-                                                 currentDate.getMonth(),
-                                                 currentDate.getDate() + 1));
+                        return Date.UTC(currentYear, currentMonth, currentMonthDay + 1);
                     }
 
                     enabled: root.expireDateEnabled &&
                              !root.waitingForExpireDateChange &&
                              !root.waitingForExpireDateEnabledChange
 
+                    onUserAcceptedDate: {
+                        root.setExpireDate(dateInMs);
+                        root.waitingForExpireDateChange = true;
+                    }
+
                     NCBusyIndicator {
                         anchors.fill: parent
                         visible: root.waitingForExpireDateEnabledChange ||