diff --git a/backend/app/api/static/docs/docs.go b/backend/app/api/static/docs/docs.go index 1af68fee..d08de9b6 100644 --- a/backend/app/api/static/docs/docs.go +++ b/backend/app/api/static/docs/docs.go @@ -118,6 +118,41 @@ const docTemplate = `{ } } }, + "/v1/actions/wipe-inventory": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Deletes all items in the inventory", + "produces": [ + "application/json" + ], + "tags": [ + "Actions" + ], + "summary": "Wipe Inventory", + "parameters": [ + { + "description": "Wipe options", + "name": "options", + "in": "body", + "schema": { + "$ref": "#/definitions/v1.WipeInventoryOptions" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/v1.ActionAmountResult" + } + } + } + } + }, "/v1/actions/zero-item-time-fields": { "post": { "security": [ @@ -5184,6 +5219,20 @@ const docTemplate = `{ } } }, + "v1.WipeInventoryOptions": { + "type": "object", + "properties": { + "wipeLabels": { + "type": "boolean" + }, + "wipeLocations": { + "type": "boolean" + }, + "wipeMaintenance": { + "type": "boolean" + } + } + }, "v1.Wrapped": { "type": "object", "properties": { diff --git a/backend/app/api/static/docs/openapi-3.json b/backend/app/api/static/docs/openapi-3.json index a80a6124..f4ce81bf 100644 --- a/backend/app/api/static/docs/openapi-3.json +++ b/backend/app/api/static/docs/openapi-3.json @@ -114,6 +114,42 @@ } } }, + "/v1/actions/wipe-inventory": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Deletes all items in the inventory", + "tags": [ + "Actions" + ], + "summary": "Wipe Inventory", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/v1.WipeInventoryOptions" + } + } + }, + "description": "Wipe options" + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/v1.ActionAmountResult" + } + } + } + } + } + } + }, "/v1/actions/zero-item-time-fields": { "post": { "security": [ @@ -5381,6 +5417,20 @@ } } }, + "v1.WipeInventoryOptions": { + "type": "object", + "properties": { + "wipeLabels": { + "type": "boolean" + }, + "wipeLocations": { + "type": "boolean" + }, + "wipeMaintenance": { + "type": "boolean" + } + } + }, "v1.Wrapped": { "type": "object", "properties": { diff --git a/backend/app/api/static/docs/openapi-3.yaml b/backend/app/api/static/docs/openapi-3.yaml index 0a6d2042..eda39cf7 100644 --- a/backend/app/api/static/docs/openapi-3.yaml +++ b/backend/app/api/static/docs/openapi-3.yaml @@ -67,6 +67,27 @@ paths: application/json: schema: $ref: "#/components/schemas/v1.ActionAmountResult" + /v1/actions/wipe-inventory: + post: + security: + - Bearer: [] + description: Deletes all items in the inventory + tags: + - Actions + summary: Wipe Inventory + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/v1.WipeInventoryOptions" + description: Wipe options + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/v1.ActionAmountResult" /v1/actions/zero-item-time-fields: post: security: @@ -3449,6 +3470,15 @@ components: type: string token: type: string + v1.WipeInventoryOptions: + type: object + properties: + wipeLabels: + type: boolean + wipeLocations: + type: boolean + wipeMaintenance: + type: boolean v1.Wrapped: type: object properties: diff --git a/backend/app/api/static/docs/swagger.json b/backend/app/api/static/docs/swagger.json index 61b8612a..cb5a49f4 100644 --- a/backend/app/api/static/docs/swagger.json +++ b/backend/app/api/static/docs/swagger.json @@ -116,6 +116,41 @@ } } }, + "/v1/actions/wipe-inventory": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Deletes all items in the inventory", + "produces": [ + "application/json" + ], + "tags": [ + "Actions" + ], + "summary": "Wipe Inventory", + "parameters": [ + { + "description": "Wipe options", + "name": "options", + "in": "body", + "schema": { + "$ref": "#/definitions/v1.WipeInventoryOptions" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/v1.ActionAmountResult" + } + } + } + } + }, "/v1/actions/zero-item-time-fields": { "post": { "security": [ @@ -5182,6 +5217,20 @@ } } }, + "v1.WipeInventoryOptions": { + "type": "object", + "properties": { + "wipeLabels": { + "type": "boolean" + }, + "wipeLocations": { + "type": "boolean" + }, + "wipeMaintenance": { + "type": "boolean" + } + } + }, "v1.Wrapped": { "type": "object", "properties": { diff --git a/backend/app/api/static/docs/swagger.yaml b/backend/app/api/static/docs/swagger.yaml index d18a8f45..0d234331 100644 --- a/backend/app/api/static/docs/swagger.yaml +++ b/backend/app/api/static/docs/swagger.yaml @@ -1867,6 +1867,15 @@ definitions: token: type: string type: object + v1.WipeInventoryOptions: + properties: + wipeLabels: + type: boolean + wipeLocations: + type: boolean + wipeMaintenance: + type: boolean + type: object v1.Wrapped: properties: item: {} @@ -1947,6 +1956,27 @@ paths: summary: Set Primary Photos tags: - Actions + /v1/actions/wipe-inventory: + post: + description: Deletes all items in the inventory + parameters: + - description: Wipe options + in: body + name: options + schema: + $ref: '#/definitions/v1.WipeInventoryOptions' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/v1.ActionAmountResult' + security: + - Bearer: [] + summary: Wipe Inventory + tags: + - Actions /v1/actions/zero-item-time-fields: post: description: Resets all item date fields to the beginning of the day diff --git a/backend/go.sum b/backend/go.sum index 6f11d8f1..0d766402 100644 --- a/backend/go.sum +++ b/backend/go.sum @@ -325,6 +325,8 @@ github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/ github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0= +github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/mattn/go-sqlite3 v1.14.32 h1:JD12Ag3oLy1zQA+BNn74xRgaBbdhbNIDYvQUEuuErjs= github.com/mattn/go-sqlite3 v1.14.32/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y= github.com/mfridman/interpolate v0.0.2 h1:pnuTK7MQIxxFz1Gr+rjSIx9u7qVjf5VOoM/u6BbAxPY= @@ -347,6 +349,8 @@ github.com/ncruces/go-strftime v1.0.0 h1:HMFp8mLCTPp341M/ZnA4qaf7ZlsbTc+miZjCLOF github.com/ncruces/go-strftime v1.0.0/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls= github.com/olahol/melody v1.4.0 h1:Pa5SdeZL/zXPi1tJuMAPDbl4n3gQOThSL6G1p4qZ4SI= github.com/olahol/melody v1.4.0/go.mod h1:GgkTl6Y7yWj/HtfD48Q5vLKPVoZOH+Qqgfa7CvJgJM4= +github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= +github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/onsi/ginkgo/v2 v2.9.2 h1:BA2GMJOtfGAfagzYtrAlufIP0lq6QERkFmHLMLPwFSU= github.com/onsi/ginkgo/v2 v2.9.2/go.mod h1:WHcJJG2dIlcCqVfBAwUCrJxSPFb6v4azBwgxeMeDuts= github.com/onsi/gomega v1.27.6 h1:ENqfyGeS5AX/rlXDd/ETokDz93u0YufY1Pgxuy/PvWE= @@ -389,6 +393,10 @@ github.com/shirou/gopsutil/v4 v4.25.11 h1:X53gB7muL9Gnwwo2evPSE+SfOrltMoR6V3xJAX github.com/shirou/gopsutil/v4 v4.25.11/go.mod h1:EivAfP5x2EhLp2ovdpKSozecVXn1TmuG7SMzs/Wh4PU= github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e h1:MRM5ITcdelLK2j1vwZ3Je0FKVCfqOLp5zO6trqMLYs0= github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e/go.mod h1:XV66xRDqSt+GTGFMVlhk3ULuV0y9ZmzeVGR4mloJI3M= +github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I= +github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0= +github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= +github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spiffe/go-spiffe/v2 v2.6.0 h1:l+DolpxNWYgruGQVV0xsfeya3CsC7m8iBzDnMpsbLuo= github.com/spiffe/go-spiffe/v2 v2.6.0/go.mod h1:gm2SeUoMZEtpnzPNs2Csc0D/gX33k1xIx7lEzqblHEs= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= diff --git a/docs/en/api/openapi-2.0.json b/docs/en/api/openapi-2.0.json index cd4721fa..cb5a49f4 100644 --- a/docs/en/api/openapi-2.0.json +++ b/docs/en/api/openapi-2.0.json @@ -116,6 +116,41 @@ } } }, + "/v1/actions/wipe-inventory": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Deletes all items in the inventory", + "produces": [ + "application/json" + ], + "tags": [ + "Actions" + ], + "summary": "Wipe Inventory", + "parameters": [ + { + "description": "Wipe options", + "name": "options", + "in": "body", + "schema": { + "$ref": "#/definitions/v1.WipeInventoryOptions" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/v1.ActionAmountResult" + } + } + } + } + }, "/v1/actions/zero-item-time-fields": { "post": { "security": [ @@ -4032,7 +4067,8 @@ "properties": { "defaultDescription": { "type": "string", - "maxLength": 1000 + "maxLength": 1000, + "x-nullable": true }, "defaultInsured": { "type": "boolean" @@ -4041,34 +4077,41 @@ "type": "array", "items": { "type": "string" - } + }, + "x-nullable": true }, "defaultLifetimeWarranty": { "type": "boolean" }, "defaultLocationId": { "description": "Default location and labels", - "type": "string" + "type": "string", + "x-nullable": true }, "defaultManufacturer": { "type": "string", - "maxLength": 255 + "maxLength": 255, + "x-nullable": true }, "defaultModelNumber": { "type": "string", - "maxLength": 255 + "maxLength": 255, + "x-nullable": true }, "defaultName": { "type": "string", - "maxLength": 255 + "maxLength": 255, + "x-nullable": true }, "defaultQuantity": { "description": "Default values for items", - "type": "integer" + "type": "integer", + "x-nullable": true }, "defaultWarrantyDetails": { "type": "string", - "maxLength": 1000 + "maxLength": 1000, + "x-nullable": true }, "description": { "type": "string", @@ -4209,7 +4252,8 @@ "properties": { "defaultDescription": { "type": "string", - "maxLength": 1000 + "maxLength": 1000, + "x-nullable": true }, "defaultInsured": { "type": "boolean" @@ -4218,34 +4262,41 @@ "type": "array", "items": { "type": "string" - } + }, + "x-nullable": true }, "defaultLifetimeWarranty": { "type": "boolean" }, "defaultLocationId": { "description": "Default location and labels", - "type": "string" + "type": "string", + "x-nullable": true }, "defaultManufacturer": { "type": "string", - "maxLength": 255 + "maxLength": 255, + "x-nullable": true }, "defaultModelNumber": { "type": "string", - "maxLength": 255 + "maxLength": 255, + "x-nullable": true }, "defaultName": { "type": "string", - "maxLength": 255 + "maxLength": 255, + "x-nullable": true }, "defaultQuantity": { "description": "Default values for items", - "type": "integer" + "type": "integer", + "x-nullable": true }, "defaultWarrantyDetails": { "type": "string", - "maxLength": 1000 + "maxLength": 1000, + "x-nullable": true }, "description": { "type": "string", @@ -5166,6 +5217,20 @@ } } }, + "v1.WipeInventoryOptions": { + "type": "object", + "properties": { + "wipeLabels": { + "type": "boolean" + }, + "wipeLocations": { + "type": "boolean" + }, + "wipeMaintenance": { + "type": "boolean" + } + } + }, "v1.Wrapped": { "type": "object", "properties": { diff --git a/docs/en/api/openapi-2.0.yaml b/docs/en/api/openapi-2.0.yaml index 8926c617..0d234331 100644 --- a/docs/en/api/openapi-2.0.yaml +++ b/docs/en/api/openapi-2.0.yaml @@ -1084,32 +1084,40 @@ definitions: defaultDescription: maxLength: 1000 type: string + x-nullable: true defaultInsured: type: boolean defaultLabelIds: items: type: string type: array + x-nullable: true defaultLifetimeWarranty: type: boolean defaultLocationId: description: Default location and labels type: string + x-nullable: true defaultManufacturer: maxLength: 255 type: string + x-nullable: true defaultModelNumber: maxLength: 255 type: string + x-nullable: true defaultName: maxLength: 255 type: string + x-nullable: true defaultQuantity: description: Default values for items type: integer + x-nullable: true defaultWarrantyDetails: maxLength: 1000 type: string + x-nullable: true description: maxLength: 1000 type: string @@ -1205,32 +1213,40 @@ definitions: defaultDescription: maxLength: 1000 type: string + x-nullable: true defaultInsured: type: boolean defaultLabelIds: items: type: string type: array + x-nullable: true defaultLifetimeWarranty: type: boolean defaultLocationId: description: Default location and labels type: string + x-nullable: true defaultManufacturer: maxLength: 255 type: string + x-nullable: true defaultModelNumber: maxLength: 255 type: string + x-nullable: true defaultName: maxLength: 255 type: string + x-nullable: true defaultQuantity: description: Default values for items type: integer + x-nullable: true defaultWarrantyDetails: maxLength: 1000 type: string + x-nullable: true description: maxLength: 1000 type: string @@ -1851,6 +1867,15 @@ definitions: token: type: string type: object + v1.WipeInventoryOptions: + properties: + wipeLabels: + type: boolean + wipeLocations: + type: boolean + wipeMaintenance: + type: boolean + type: object v1.Wrapped: properties: item: {} @@ -1931,6 +1956,27 @@ paths: summary: Set Primary Photos tags: - Actions + /v1/actions/wipe-inventory: + post: + description: Deletes all items in the inventory + parameters: + - description: Wipe options + in: body + name: options + schema: + $ref: '#/definitions/v1.WipeInventoryOptions' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/v1.ActionAmountResult' + security: + - Bearer: [] + summary: Wipe Inventory + tags: + - Actions /v1/actions/zero-item-time-fields: post: description: Resets all item date fields to the beginning of the day diff --git a/docs/en/api/openapi-3.0.json b/docs/en/api/openapi-3.0.json index a80a6124..f4ce81bf 100644 --- a/docs/en/api/openapi-3.0.json +++ b/docs/en/api/openapi-3.0.json @@ -114,6 +114,42 @@ } } }, + "/v1/actions/wipe-inventory": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Deletes all items in the inventory", + "tags": [ + "Actions" + ], + "summary": "Wipe Inventory", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/v1.WipeInventoryOptions" + } + } + }, + "description": "Wipe options" + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/v1.ActionAmountResult" + } + } + } + } + } + } + }, "/v1/actions/zero-item-time-fields": { "post": { "security": [ @@ -5381,6 +5417,20 @@ } } }, + "v1.WipeInventoryOptions": { + "type": "object", + "properties": { + "wipeLabels": { + "type": "boolean" + }, + "wipeLocations": { + "type": "boolean" + }, + "wipeMaintenance": { + "type": "boolean" + } + } + }, "v1.Wrapped": { "type": "object", "properties": { diff --git a/docs/en/api/openapi-3.0.yaml b/docs/en/api/openapi-3.0.yaml index 0a6d2042..eda39cf7 100644 --- a/docs/en/api/openapi-3.0.yaml +++ b/docs/en/api/openapi-3.0.yaml @@ -67,6 +67,27 @@ paths: application/json: schema: $ref: "#/components/schemas/v1.ActionAmountResult" + /v1/actions/wipe-inventory: + post: + security: + - Bearer: [] + description: Deletes all items in the inventory + tags: + - Actions + summary: Wipe Inventory + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/v1.WipeInventoryOptions" + description: Wipe options + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/v1.ActionAmountResult" /v1/actions/zero-item-time-fields: post: security: @@ -3449,6 +3470,15 @@ components: type: string token: type: string + v1.WipeInventoryOptions: + type: object + properties: + wipeLabels: + type: boolean + wipeLocations: + type: boolean + wipeMaintenance: + type: boolean v1.Wrapped: type: object properties: diff --git a/docs/en/api/swagger-2.0.json b/docs/en/api/swagger-2.0.json index 61b8612a..cb5a49f4 100644 --- a/docs/en/api/swagger-2.0.json +++ b/docs/en/api/swagger-2.0.json @@ -116,6 +116,41 @@ } } }, + "/v1/actions/wipe-inventory": { + "post": { + "security": [ + { + "Bearer": [] + } + ], + "description": "Deletes all items in the inventory", + "produces": [ + "application/json" + ], + "tags": [ + "Actions" + ], + "summary": "Wipe Inventory", + "parameters": [ + { + "description": "Wipe options", + "name": "options", + "in": "body", + "schema": { + "$ref": "#/definitions/v1.WipeInventoryOptions" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/v1.ActionAmountResult" + } + } + } + } + }, "/v1/actions/zero-item-time-fields": { "post": { "security": [ @@ -5182,6 +5217,20 @@ } } }, + "v1.WipeInventoryOptions": { + "type": "object", + "properties": { + "wipeLabels": { + "type": "boolean" + }, + "wipeLocations": { + "type": "boolean" + }, + "wipeMaintenance": { + "type": "boolean" + } + } + }, "v1.Wrapped": { "type": "object", "properties": { diff --git a/docs/en/api/swagger-2.0.yaml b/docs/en/api/swagger-2.0.yaml index d18a8f45..0d234331 100644 --- a/docs/en/api/swagger-2.0.yaml +++ b/docs/en/api/swagger-2.0.yaml @@ -1867,6 +1867,15 @@ definitions: token: type: string type: object + v1.WipeInventoryOptions: + properties: + wipeLabels: + type: boolean + wipeLocations: + type: boolean + wipeMaintenance: + type: boolean + type: object v1.Wrapped: properties: item: {} @@ -1947,6 +1956,27 @@ paths: summary: Set Primary Photos tags: - Actions + /v1/actions/wipe-inventory: + post: + description: Deletes all items in the inventory + parameters: + - description: Wipe options + in: body + name: options + schema: + $ref: '#/definitions/v1.WipeInventoryOptions' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/v1.ActionAmountResult' + security: + - Bearer: [] + summary: Wipe Inventory + tags: + - Actions /v1/actions/zero-item-time-fields: post: description: Resets all item date fields to the beginning of the day diff --git a/frontend/components/WipeInventoryDialog.vue b/frontend/components/WipeInventoryDialog.vue index 64bf33c2..7fc9502d 100644 --- a/frontend/components/WipeInventoryDialog.vue +++ b/frontend/components/WipeInventoryDialog.vue @@ -82,12 +82,14 @@ const wipeLabels = ref(false); const wipeLocations = ref(false); const wipeMaintenance = ref(false); + const isConfirming = ref(false); registerOpenDialogCallback(DialogID.WipeInventory, () => { dialog.value = true; wipeLabels.value = false; wipeLocations.value = false; wipeMaintenance.value = false; + isConfirming.value = false; }); watch( @@ -103,7 +105,7 @@ ); function handleOpenChange(open: boolean) { - if (!open) { + if (!open && !isConfirming.value) { close(); } } @@ -114,12 +116,13 @@ } function confirm() { - dialog.value = false; + isConfirming.value = true; const result = { wipeLabels: wipeLabels.value, wipeLocations: wipeLocations.value, wipeMaintenance: wipeMaintenance.value, }; + dialog.value = false; closeDialog(DialogID.WipeInventory, result); } diff --git a/frontend/lib/api/types/data-contracts.ts b/frontend/lib/api/types/data-contracts.ts index 10414206..3f7e283c 100644 --- a/frontend/lib/api/types/data-contracts.ts +++ b/frontend/lib/api/types/data-contracts.ts @@ -1150,6 +1150,12 @@ export interface TokenResponse { token: string; } +export interface WipeInventoryOptions { + wipeLabels: boolean; + wipeLocations: boolean; + wipeMaintenance: boolean; +} + export interface Wrapped { item: any; }