Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CP-3218] Delete files #2243

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const fileManagerView: View = {
"audioFiles",
"imageFiles",
"ebookFiles",
"applicationFiles",
// "applicationFiles",
],
},
// @ts-ignore
Expand Down
216 changes: 216 additions & 0 deletions libs/generic-view/ui/src/lib/generated/mc-file-manager/delete-files.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,216 @@
/**
* Copyright (c) Mudita sp. z o.o. All rights reserved.
* For licensing, see https://github.com/mudita/mudita-center/blob/master/LICENSE.md
*/

import { Subview, IconType } from "generic-view/utils"

export const generateDeleteFiles = (
id: string,
entitiesType: string
): Subview => {
return {
[`${id}deleteModal`]: {
component: "modal",
config: {
size: "small",
},
childrenKeys: [
`${id}deleteModalIcon`,
`${id}deleteModalTitle`,
`${id}deleteModalContent`,
`${id}deleteModalButtons`,
],
},
[`${id}deleteModalIcon`]: {
component: "modal.titleIcon",
config: {
type: IconType.Exclamation,
},
},
[`${id}deleteModalTitle`]: {
component: "modal.title",
childrenKeys: [`${id}deleteModalTitleText`],
},
[`${id}deleteModalTitleText`]: {
component: "format-message",
config: {
messageTemplate:
"Delete {selectedItems, plural, one {file} other {# files}}?",
},
dataProvider: {
source: "form-fields",
formKey: `${id}fileListForm`,
fields: [
{
providerField: "selectedItems",
componentField: "data.fields.selectedItems",
modifier: "length",
},
],
},
},
[`${id}deleteModalContent`]: {
component: "p1-component",
childrenKeys: [`${id}deleteModalContentText`],
},
[`${id}deleteModalContentText`]: {
component: "format-message",
config: {
messageTemplate:
"This will remove the {selectedItems, plural, one {file} other {files}} from Kompakt.",
},
dataProvider: {
source: "form-fields",
formKey: `${id}fileListForm`,
fields: [
{
providerField: "selectedItems",
componentField: "data.fields.selectedItems",
modifier: "length",
},
],
},
},
[`${id}deleteModalButtons`]: {
component: "modal.buttons",
childrenKeys: [
`${id}deleteModalCancelButton`,
`${id}deleteModalConfirmButton`,
],
},
[`${id}deleteModalCancelButton`]: {
component: "button-secondary",
config: {
text: "Cancel",
actions: [
{
type: "close-modal",
modalKey: `${id}deleteModal`,
},
],
},
},
[`${id}deleteModalConfirmButton`]: {
component: "button-primary",
config: {
actions: [
{
type: "open-modal",
modalKey: `${id}deleteProgressModal`,
domain: "files-delete",
},
{
type: "entities-delete",
entitiesType,
ids: [],
postActions: {
success: [
{
type: "close-domain-modals",
domain: "files-delete",
},
{
type: "open-toast",
toastKey: `${id}filesDeletedToast`,
},
],
},
},
],
},
childrenKeys: [`${id}deleteModalConfirmButtonText`],
layout: {
flexLayout: {
direction: "row",
justifyContent: "center",
},
},
dataProvider: {
source: "form-fields",
formKey: `${id}fileListForm`,
fields: [
{
providerField: "selectedItems",
componentField: "config.actions[1].ids",
},
],
},
},
[`${id}deleteModalConfirmButtonText`]: {
component: "format-message",
config: {
messageTemplate:
"Delete {selectedItems, plural, one {file} other {files}}",
},
dataProvider: {
source: "form-fields",
formKey: `${id}fileListForm`,
fields: [
{
providerField: "selectedItems",
componentField: "data.fields.selectedItems",
modifier: "length",
},
],
},
},
[`${id}filesDeletedToast`]: {
component: "toast",
childrenKeys: [
`${id}filesDeletedToastIcon`,
`${id}filesDeletedToastText`,
],
},
[`${id}filesDeletedToastIcon`]: {
component: "icon",
config: {
type: IconType.Success,
},
},
[`${id}filesDeletedToastText`]: {
component: "p1-component",
childrenKeys: [`${id}filesDeletedToastMessage`],
},
[`${id}filesDeletedToastMessage`]: {
component: "format-message",
config: {
messageTemplate:
"{selectedItems} {selectedItems, plural, one {file} other {files}} deleted",
},
dataProvider: {
source: "form-fields",
formKey: `${id}fileListForm`,
fields: [
{
providerField: "selectedItems",
componentField: "data.fields.selectedItems",
modifier: "length",
},
],
},
},
[`${id}deleteProgressModal`]: {
component: "modal",
config: {
size: "small",
},
childrenKeys: [
`${id}deleteProgressModalIcon`,
`${id}deleteProgressModalTitle`,
],
},
[`${id}deleteProgressModalIcon`]: {
component: "modal.titleIcon",
config: {
type: IconType.SpinnerDark,
},
},
[`${id}deleteProgressModalTitle`]: {
component: "modal.title",
config: {
text: "Deleting, please wait...",
},
},
}
}
Loading
Loading