feat: use AI to migrate DateTimePicker component
This commit is contained in:
@@ -37,13 +37,13 @@ const refreshOwnedItem = async () => {
|
||||
ownedItems.value.clear();
|
||||
|
||||
// Fetch data
|
||||
let rv = await apiCollectionGetFullOwn(token.currentToken);
|
||||
const rv = await apiCollectionGetFullOwn(token.currentToken);
|
||||
if (typeof rv === 'undefined') {
|
||||
console.error("fail to fetch owned collection");
|
||||
return;
|
||||
}
|
||||
// Add into dict for rendering
|
||||
for (let item of rv) {
|
||||
for (const item of rv) {
|
||||
ownedItems.value.set(item[0], item);
|
||||
}
|
||||
|
||||
@@ -53,20 +53,20 @@ const refreshOwnedItem = async () => {
|
||||
}
|
||||
|
||||
const addOwnedItem = async () => {
|
||||
let new_name = pendingOwnedItemName.value;
|
||||
const new_name = pendingOwnedItemName.value;
|
||||
if (new_name === '') {
|
||||
return
|
||||
}
|
||||
|
||||
// first add it
|
||||
let rv = await apiCollectionAddOwn(token.currentToken, new_name);
|
||||
const rv = await apiCollectionAddOwn(token.currentToken, new_name);
|
||||
if (typeof rv === 'undefined') {
|
||||
messagebox.value?.show("An add operation failed. It may caused by wrong arguments. Refreshing page may fix system problem. Before refreshing page, please backup all your unsaved data.");
|
||||
return;
|
||||
}
|
||||
|
||||
// second get its detail
|
||||
let rv2 = await apiCollectionGetDetailOwn(token.currentToken, rv);
|
||||
const rv2 = await apiCollectionGetDetailOwn(token.currentToken, rv);
|
||||
if (typeof rv2 === 'undefined') {
|
||||
messagebox.value?.show("A get operation failed. It may caused by server internal error or your limited permission. Refreshing page may fix system problem. Before refreshing page, please backup all your unsaved data.");
|
||||
return;
|
||||
@@ -77,7 +77,7 @@ const addOwnedItem = async () => {
|
||||
}
|
||||
|
||||
const deleteOwnedItem = async (uuid: string) => {
|
||||
let rv = await apiCollectionDeleteOwn(token.currentToken, uuid, ownedItems.value.get(uuid)![2]);
|
||||
const rv = await apiCollectionDeleteOwn(token.currentToken, uuid, ownedItems.value.get(uuid)![2]);
|
||||
if (rv) {
|
||||
messagebox.value?.show("A delete operation failed. It may caused by no matched item. Refreshing page may fix system problem. Before refreshing page, please backup all your unsaved data.");
|
||||
return;
|
||||
@@ -97,7 +97,7 @@ const deleteOwnedItem = async (uuid: string) => {
|
||||
const shareOwnedItem = async (uuid: string) => {
|
||||
// if there is no editing sharing target, set it.
|
||||
// otherwise override it or toggle it according to its old value.
|
||||
let old_value = sharingItemUuid.value;
|
||||
const old_value = sharingItemUuid.value;
|
||||
if (typeof old_value === 'string') {
|
||||
if (old_value === uuid) {
|
||||
sharingItemUuid.value = null;
|
||||
@@ -112,15 +112,15 @@ const shareOwnedItem = async (uuid: string) => {
|
||||
}
|
||||
|
||||
const updateOwnedItem = async (uuid: string, name: string) => {
|
||||
let lastChange = ownedItems.value.get(uuid)![2];
|
||||
let rv = await apiCollectionUpdateOwn(token.currentToken, uuid, name, lastChange);
|
||||
const lastChange = ownedItems.value.get(uuid)![2];
|
||||
const rv = await apiCollectionUpdateOwn(token.currentToken, uuid, name, lastChange);
|
||||
if (typeof rv === 'undefined') {
|
||||
messagebox.value?.show("An update operation failed. It may caused by wrong arguments or lost target. Refreshing page may fix system problem. Before refreshing page, please backup all your unsaved data.");
|
||||
return;
|
||||
}
|
||||
|
||||
// return value is new lastChange, so we update it.
|
||||
let row = ownedItems.value.get(uuid)!;
|
||||
const row = ownedItems.value.get(uuid)!;
|
||||
row[1] = name;
|
||||
row[2] = rv;
|
||||
|
||||
@@ -140,8 +140,8 @@ const refreshSharingItem = async () => {
|
||||
}
|
||||
|
||||
// fetch data
|
||||
let uuid = sharingItemUuid.value!;
|
||||
let rv = await apiCollectionGetSharing(token.currentToken, uuid);
|
||||
const uuid = sharingItemUuid.value!;
|
||||
const rv = await apiCollectionGetSharing(token.currentToken, uuid);
|
||||
if (typeof rv === 'undefined') {
|
||||
console.error(`fail to fetch sharing target for collection ${uuid}`);
|
||||
return;
|
||||
@@ -152,15 +152,15 @@ const refreshSharingItem = async () => {
|
||||
}
|
||||
|
||||
const addSharingItem = async () => {
|
||||
let uuid = sharingItemUuid.value!;
|
||||
let lastChange = ownedItems.value.get(uuid)![2];
|
||||
let new_username = pendingSharingItemUsername.value;
|
||||
const uuid = sharingItemUuid.value!;
|
||||
const lastChange = ownedItems.value.get(uuid)![2];
|
||||
const new_username = pendingSharingItemUsername.value;
|
||||
if (new_username === '') {
|
||||
return;
|
||||
}
|
||||
|
||||
// order adding
|
||||
let rv = await apiCollectionAddSharing(token.currentToken, uuid, new_username, lastChange);
|
||||
const rv = await apiCollectionAddSharing(token.currentToken, uuid, new_username, lastChange);
|
||||
if (typeof rv === 'undefined') {
|
||||
messagebox.value?.show("An add operation failed. It may caused by wrong arguments. Refreshing page may fix system problem. Before refreshing page, please backup all your unsaved data.");
|
||||
return;
|
||||
@@ -173,11 +173,11 @@ const addSharingItem = async () => {
|
||||
}
|
||||
|
||||
const deleteSharingItem = async (username: string) => {
|
||||
let uuid = sharingItemUuid.value!;
|
||||
let lastChange = ownedItems.value.get(uuid)![2];
|
||||
const uuid = sharingItemUuid.value!;
|
||||
const lastChange = ownedItems.value.get(uuid)![2];
|
||||
|
||||
// order deleting
|
||||
let rv = await apiCollectionDeleteSharing(token.currentToken, uuid, username, lastChange);
|
||||
const rv = await apiCollectionDeleteSharing(token.currentToken, uuid, username, lastChange);
|
||||
if (typeof rv === 'undefined') {
|
||||
messagebox.value?.show("A delete operation failed. It may caused by no matched item. Refreshing page may fix system problem. Before refreshing page, please backup all your unsaved data.");
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user