fix upload

This commit is contained in:
samunohito
2024-02-26 08:29:35 +09:00
parent 390af67949
commit b60951e7ea
2 changed files with 19 additions and 10 deletions
@@ -252,17 +252,21 @@ function setupGrid(): GridSetting {
row: {
showNumber: true,
selectable: true,
// グリッドの行数をあらかじめ100行確保する
minimumDefinitionCount: 100,
styleRules: [
{
// 初期値から変わっていたら背景色を変更
condition: ({ row }) => JSON.stringify(gridItems.value[row.index]) !== JSON.stringify(originGridItems.value[row.index]),
applyStyle: { className: 'changedRow' },
},
{
// バリデーションに引っかかっていたら背景色を変更
condition: ({ cells }) => cells.some(it => !it.violation.valid),
applyStyle: { className: 'violationRow' },
},
],
// 行のコンテキストメニュー設定
contextMenuFactory: (row, context) => {
return [
{
@@ -285,6 +289,7 @@ function setupGrid(): GridSetting {
},
events: {
delete(rows) {
// 行削除時は元データの行を消さず、削除対象としてマークするのみにする
for (const row of rows) {
gridItems.value[row.index].checked = true;
}
@@ -351,6 +356,7 @@ function setupGrid(): GridSetting {
{ bindTo: 'originalUrl', type: 'text', editable: false, width: 180 },
],
cells: {
// セルのコンテキストメニュー設定
contextMenuFactory(col, row, value, context) {
return [
{
@@ -136,10 +136,12 @@ function setupGrid(): GridSetting {
minimumDefinitionCount: 100,
styleRules: [
{
// 1つでもバリデーションエラーがあれば行全体をエラー表示する
condition: ({ cells }) => cells.some(it => !it.violation.valid),
applyStyle: { className: 'violationRow' },
},
],
// 行のコンテキストメニュー設定
contextMenuFactory: (row, context) => {
return [
{
@@ -209,6 +211,7 @@ function setupGrid(): GridSetting {
},
],
cells: {
// セルのコンテキストメニュー設定
contextMenuFactory: (col, row, value, context) => {
return [
{
@@ -307,9 +310,18 @@ async function onClearClicked() {
async function onDrop(ev: DragEvent) {
isDragOver.value = false;
const droppedFiles = await extractDroppedItems(ev).then(it => flattenDroppedFiles(it));
const confirm = await os.confirm({
type: 'info',
title: '確認',
text: `ドラッグ&ドロップされた${droppedFiles.length}個のファイルをドライブにアップロードします。実行しますか?`,
});
if (confirm.canceled) {
return;
}
const uploadedItems = Array.of<{ droppedFile: DroppedFile, driveFile: Misskey.entities.DriveFile }>();
try {
const droppedFiles = await extractDroppedItems(ev).then(it => flattenDroppedFiles(it));
uploadedItems.push(
...await os.promiseDialog(
Promise.all(
@@ -335,15 +347,6 @@ async function onDrop(ev: DragEvent) {
return;
}
const confirm = await os.confirm({
type: 'info',
title: '確認',
text: `ドラッグ&ドロップされた${uploadedItems.length}個のファイルをドライブにアップロードします。実行しますか?`,
});
if (confirm.canceled) {
return;
}
const items = uploadedItems.map(({ droppedFile, driveFile }) => {
const item = fromDriveFile(driveFile);
if (directoryToCategory.value) {