diff --git a/core-web/libs/data-access/src/lib/dot-upload-file/dot-upload-file.service.ts b/core-web/libs/data-access/src/lib/dot-upload-file/dot-upload-file.service.ts index 42eeef06aab7..9a2c676b7592 100644 --- a/core-web/libs/data-access/src/lib/dot-upload-file/dot-upload-file.service.ts +++ b/core-web/libs/data-access/src/lib/dot-upload-file/dot-upload-file.service.ts @@ -91,19 +91,20 @@ export class DotUploadFileService { } uploadDotAsset(file: File): Observable { - const formData = new FormData(); formData.append('file', file); - formData.append('json', JSON.stringify({ - contentlet: { - file: file.name, - contentType : 'dotAsset' - } - })); - - return this.http.put(`/api/v1/workflow/actions/default/fire/NEW`, formData) - .pipe( - pluck('entity') + formData.append( + 'json', + JSON.stringify({ + contentlet: { + file: file.name, + contentType: 'dotAsset' + } + }) ); + + return this.http + .put(`/api/v1/workflow/actions/default/fire/NEW`, formData) + .pipe(pluck('entity')); } } diff --git a/core-web/libs/edit-content/src/lib/fields/dot-edit-content-file-field/components/dot-file-field-ui-message/dot-file-field-ui-message.component.html b/core-web/libs/edit-content/src/lib/fields/dot-edit-content-file-field/components/dot-file-field-ui-message/dot-file-field-ui-message.component.html index 669b8818fee7..f77e24d304bf 100644 --- a/core-web/libs/edit-content/src/lib/fields/dot-edit-content-file-field/components/dot-file-field-ui-message/dot-file-field-ui-message.component.html +++ b/core-web/libs/edit-content/src/lib/fields/dot-edit-content-file-field/components/dot-file-field-ui-message/dot-file-field-ui-message.component.html @@ -1,12 +1,11 @@ @let uiMessage = $uiMessage(); -
+
- +
diff --git a/core-web/libs/edit-content/src/lib/fields/dot-edit-content-file-field/dot-edit-content-file-field.component.ts b/core-web/libs/edit-content/src/lib/fields/dot-edit-content-file-field/dot-edit-content-file-field.component.ts index 116521a1853c..12b40173ebf4 100644 --- a/core-web/libs/edit-content/src/lib/fields/dot-edit-content-file-field/dot-edit-content-file-field.component.ts +++ b/core-web/libs/edit-content/src/lib/fields/dot-edit-content-file-field/dot-edit-content-file-field.component.ts @@ -72,10 +72,10 @@ export class DotEditContentFileFieldComponent implements ControlValueAccessor, O ngOnInit() { console.log('content', this.$contentlet()); - + this.store.initLoad({ fieldVariable: this.$field().variable, - inputType: this.$field().fieldType as INPUT_TYPES, + inputType: this.$field().fieldType as INPUT_TYPES }); } diff --git a/core-web/libs/edit-content/src/lib/fields/dot-edit-content-file-field/models/index.ts b/core-web/libs/edit-content/src/lib/fields/dot-edit-content-file-field/models/index.ts index bcef3fc2a5c3..fd20a59884d7 100644 --- a/core-web/libs/edit-content/src/lib/fields/dot-edit-content-file-field/models/index.ts +++ b/core-web/libs/edit-content/src/lib/fields/dot-edit-content-file-field/models/index.ts @@ -11,7 +11,12 @@ export interface UIMessage { args?: string[]; } -export type MESSAGES_TYPES = 'DEFAULT' | 'SERVER_ERROR' | 'FILE_TYPE_MISMATCH' | 'MAX_FILE_SIZE_EXCEEDED' | 'MULTIPLE_FILES_DROPPED'; +export type MESSAGES_TYPES = + | 'DEFAULT' + | 'SERVER_ERROR' + | 'FILE_TYPE_MISMATCH' + | 'MAX_FILE_SIZE_EXCEEDED' + | 'MULTIPLE_FILES_DROPPED'; export type UIMessagesMap = Record; diff --git a/core-web/libs/edit-content/src/lib/fields/dot-edit-content-file-field/store/file-field.store.ts b/core-web/libs/edit-content/src/lib/fields/dot-edit-content-file-field/store/file-field.store.ts index aa1c0eb6d855..fcfcd74a870f 100644 --- a/core-web/libs/edit-content/src/lib/fields/dot-edit-content-file-field/store/file-field.store.ts +++ b/core-web/libs/edit-content/src/lib/fields/dot-edit-content-file-field/store/file-field.store.ts @@ -14,7 +14,6 @@ import { INPUT_CONFIG } from '../dot-edit-content-file-field.const'; import { INPUT_TYPES, FILE_STATUS, UIMessage, PreviewFile } from '../models'; import { getUiMessage } from '../utils/messages'; - export interface FileFieldState { contentlet: DotCMSContentlet | null; tempFile: DotCMSTempFile | null; @@ -89,12 +88,14 @@ export const FileFieldStore = signalStore( }, setUIMessage: (uiMessage: UIMessage) => { const acceptedFiles = store.acceptedFiles(); - const maxFileSize= store.maxFileSize(); + const maxFileSize = store.maxFileSize(); - patchState(store, { uiMessage: { - ...uiMessage, - args: [acceptedFiles.join(', '), `${maxFileSize}`] - } }); + patchState(store, { + uiMessage: { + ...uiMessage, + args: [acceptedFiles.join(', '), `${maxFileSize}`] + } + }); }, removeFile: () => { patchState(store, { @@ -117,10 +118,12 @@ export const FileFieldStore = signalStore( }, handleUploadFile: rxMethod( pipe( - tap(() => patchState(store, { - dropZoneActive: false, - fileStatus: 'uploading' - })), + tap(() => + patchState(store, { + dropZoneActive: false, + fileStatus: 'uploading' + }) + ), switchMap((file) => { return fileService.uploadDotAsset(file).pipe( tapResponse({ @@ -140,8 +143,8 @@ export const FileFieldStore = signalStore( }); } }) - ) - }), + ); + }) ) ) })) diff --git a/core-web/libs/edit-content/src/lib/fields/dot-edit-content-file-field/stories/binary-field.stories.ts b/core-web/libs/edit-content/src/lib/fields/dot-edit-content-file-field/stories/binary-field.stories.ts index e1278cb31328..cc912a419a6d 100644 --- a/core-web/libs/edit-content/src/lib/fields/dot-edit-content-file-field/stories/binary-field.stories.ts +++ b/core-web/libs/edit-content/src/lib/fields/dot-edit-content-file-field/stories/binary-field.stories.ts @@ -74,4 +74,4 @@ export const ResposiveBinaryField: Story = {
` }) -}; \ No newline at end of file +}; diff --git a/core-web/libs/edit-content/src/lib/fields/dot-edit-content-file-field/stories/file-field.stories.ts b/core-web/libs/edit-content/src/lib/fields/dot-edit-content-file-field/stories/file-field.stories.ts index e365b75defb4..9e2f12826af9 100644 --- a/core-web/libs/edit-content/src/lib/fields/dot-edit-content-file-field/stories/file-field.stories.ts +++ b/core-web/libs/edit-content/src/lib/fields/dot-edit-content-file-field/stories/file-field.stories.ts @@ -95,4 +95,4 @@ export const InvalidFile: Story = {

Current value: {{ value }}

` }) -}; \ No newline at end of file +}; diff --git a/core-web/libs/edit-content/src/lib/fields/dot-edit-content-file-field/utils/index.ts b/core-web/libs/edit-content/src/lib/fields/dot-edit-content-file-field/utils/index.ts index 3ee6d847c4b4..cfb667ae0067 100644 --- a/core-web/libs/edit-content/src/lib/fields/dot-edit-content-file-field/utils/index.ts +++ b/core-web/libs/edit-content/src/lib/fields/dot-edit-content-file-field/utils/index.ts @@ -1,8 +1,6 @@ import { DotCMSContentlet, DotFileMetadata } from '@dotcms/dotcms-models'; -export const getFileMetadata = ( - contentlet: DotCMSContentlet -): DotFileMetadata => { +export const getFileMetadata = (contentlet: DotCMSContentlet): DotFileMetadata => { console.log('contentlet', contentlet); const { metaData } = contentlet; diff --git a/core-web/libs/edit-content/src/lib/fields/dot-edit-content-file-field/utils/messages.ts b/core-web/libs/edit-content/src/lib/fields/dot-edit-content-file-field/utils/messages.ts index e219156c1a78..30f188a17dc4 100644 --- a/core-web/libs/edit-content/src/lib/fields/dot-edit-content-file-field/utils/messages.ts +++ b/core-web/libs/edit-content/src/lib/fields/dot-edit-content-file-field/utils/messages.ts @@ -1,5 +1,4 @@ -import { MESSAGES_TYPES, UIMessagesMap } from "../models"; - +import { MESSAGES_TYPES, UIMessagesMap } from '../models'; export const UiMessageMap: UIMessagesMap = { DEFAULT: { @@ -31,4 +30,4 @@ export const UiMessageMap: UIMessagesMap = { export function getUiMessage(key: MESSAGES_TYPES) { return UiMessageMap[key]; -} \ No newline at end of file +}