diff --git a/app/src/protyle/render/av/col.ts b/app/src/protyle/render/av/col.ts
index 8d4bc6dc8..5baee5f17 100644
--- a/app/src/protyle/render/av/col.ts
+++ b/app/src/protyle/render/av/col.ts
@@ -6,6 +6,66 @@ import {getDefaultOperatorByType, setFilter} from "./filter";
import {genCellValue} from "./cell";
import {openMenuPanel} from "./openMenuPanel";
+export const duplicateCol = (protyle: IProtyle, type: TAVCol, avID: string, colId: string, newValue:string) => {
+ const id = Lute.NewNodeID();
+ const nameMatch = newValue.match(/^(.*) \((\d+)\)$/);
+ if (nameMatch) {
+ newValue = `${nameMatch[1]} (${parseInt(nameMatch[2]) + 1})`;
+ } else {
+ newValue = `${newValue} (1)`;
+ }
+ if (["select", "mSelect"].includes(type)) {
+ fetchPost("/api/av/renderAttributeView", {id: avID}, (response) => {
+ const data = response.data as IAV;
+ let colOptions;
+ data.view.columns.find((item) => {
+ if (item.id === colId) {
+ colOptions = item.options;
+ return true;
+ }
+ });
+ transaction(protyle, [{
+ action: "addAttrViewCol",
+ name: newValue,
+ avID,
+ type,
+ id
+ }, {
+ action: "sortAttrViewCol",
+ avID,
+ previousID: colId,
+ id
+ }, {
+ action: "updateAttrViewColOptions",
+ id,
+ avID,
+ data: colOptions
+ }], [{
+ action: "removeAttrViewCol",
+ id,
+ avID,
+ }]);
+ });
+ } else {
+ transaction(protyle, [{
+ action: "addAttrViewCol",
+ name: newValue,
+ avID,
+ type,
+ id
+ }, {
+ action: "sortAttrViewCol",
+ avID,
+ previousID: colId,
+ id
+ }], [{
+ action: "removeAttrViewCol",
+ id,
+ avID,
+ }]);
+ }
+}
+
export const getEditHTML = (options: {
protyle: IProtyle,
colId: string,
@@ -50,20 +110,24 @@ export const getEditHTML = (options: {
}
return `${html}
-