Skip to content

Commit

Permalink
feat(editor-content): apply format #29872
Browse files Browse the repository at this point in the history
  • Loading branch information
nicobytes committed Sep 25, 2024
1 parent 52d1cf7 commit 14866a2
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,19 +91,20 @@ export class DotUploadFileService {
}

uploadDotAsset(file: File): Observable<DotCMSContentlet> {

const formData = new FormData();
formData.append('file', file);
formData.append('json', JSON.stringify({
contentlet: {
file: file.name,
contentType : 'dotAsset'
}
}));

return this.http.put<DotCMSContentlet>(`/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<DotCMSContentlet>(`/api/v1/workflow/actions/default/fire/NEW`, formData)
.pipe(pluck('entity'));
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
@let uiMessage = $uiMessage();

<div
[ngClass]="uiMessage.severity"
class="icon-container"
data-testId="ui-message-icon-container">
<div [ngClass]="uiMessage.severity" class="icon-container" data-testId="ui-message-icon-container">
<i [ngClass]="uiMessage.icon" data-testId="ui-message-icon" class="icon"></i>
</div>
<div class="text">
<span [innerHTML]="uiMessage.message | dm: uiMessage?.args" data-testId="ui-message-span"></span>
<span
[innerHTML]="uiMessage.message | dm: uiMessage?.args"
data-testId="ui-message-span"></span>
<ng-content></ng-content>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -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
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<MESSAGES_TYPES, UIMessage>;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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, {
Expand All @@ -117,10 +118,12 @@ export const FileFieldStore = signalStore(
},
handleUploadFile: rxMethod<File>(
pipe(
tap(() => patchState(store, {
dropZoneActive: false,
fileStatus: 'uploading'
})),
tap(() =>
patchState(store, {
dropZoneActive: false,
fileStatus: 'uploading'
})
),
switchMap((file) => {
return fileService.uploadDotAsset(file).pipe(
tapResponse({
Expand All @@ -140,8 +143,8 @@ export const FileFieldStore = signalStore(
});
}
})
)
}),
);
})
)
)
}))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,4 @@ export const ResposiveBinaryField: Story = {
</div>
`
})
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,4 @@ export const InvalidFile: Story = {
<p>Current value: {{ value }}</p>
`
})
};
};
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { MESSAGES_TYPES, UIMessagesMap } from "../models";

import { MESSAGES_TYPES, UIMessagesMap } from '../models';

export const UiMessageMap: UIMessagesMap = {
DEFAULT: {
Expand Down Expand Up @@ -31,4 +30,4 @@ export const UiMessageMap: UIMessagesMap = {

export function getUiMessage(key: MESSAGES_TYPES) {
return UiMessageMap[key];
}
}

0 comments on commit 14866a2

Please sign in to comment.