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

Edit Contentlet: Allow File Preview #26470

Merged
merged 28 commits into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
14ef42b
dev: create file preview component
rjvelazco Oct 17, 2023
42b1e69
dev: filew preview v1
rjvelazco Oct 19, 2023
3d3d9d4
Merge branch 'master' into issue-26105-edit-contentlet-allow-file-pre…
rjvelazco Oct 19, 2023
c84160f
dev: get data preview from binary field response
rjvelazco Oct 20, 2023
30c1718
dev: show preview from tempAPI
rjvelazco Oct 23, 2023
cf2dbeb
dev: let user edit images
rjvelazco Oct 24, 2023
b535ad8
test: fix current test suit v1
rjvelazco Oct 25, 2023
3086bac
dev: tests & clean up
rjvelazco Oct 25, 2023
eb23da5
test
rjvelazco Oct 26, 2023
dafc67f
test: fix DotDropZoneComponent tests
rjvelazco Oct 26, 2023
1dc6a17
dev: fix SonarQube Warnings
rjvelazco Oct 26, 2023
91d628b
dev: fix binary field build
rjvelazco Oct 26, 2023
559b617
Merge branch 'master' into issue-26105-edit-contentlet-allow-file-pre…
rjvelazco Oct 27, 2023
c804dc8
dev: fix storybook
rjvelazco Oct 27, 2023
c948a7d
styles: responsive design for preview
rjvelazco Oct 27, 2023
ea924d6
clean up
rjvelazco Oct 27, 2023
6b3b416
docs: document components methods
rjvelazco Oct 27, 2023
16b4818
feedback v1
rjvelazco Oct 30, 2023
46327e0
feedback v2
rjvelazco Oct 30, 2023
11d48d2
feedback: pupdate tests v3
rjvelazco Oct 30, 2023
9125f29
feedback: remove CoreWebService from DotLicenseService
rjvelazco Oct 30, 2023
1d5825a
clean up
rjvelazco Oct 30, 2023
ddcf50a
feedback: fix typo
rjvelazco Oct 31, 2023
0fc65fc
clean up
rjvelazco Oct 31, 2023
40cde84
Merge branch 'master' into issue-26105-edit-contentlet-allow-file-pre…
rjvelazco Oct 31, 2023
db3f411
Merge branch 'master' into issue-26105-edit-contentlet-allow-file-pre…
rjvelazco Oct 31, 2023
307049b
clean up styles
rjvelazco Oct 31, 2023
d210bff
clean up
rjvelazco Oct 31, 2023
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
@@ -1,5 +1,6 @@
import { MonacoEditorModule } from '@materia-ui/ngx-monaco-editor';

import { HttpClientModule } from '@angular/common/http';
import { DoBootstrap, Injector, NgModule, Type } from '@angular/core';
import { createCustomElement } from '@angular/elements';
import { BrowserModule } from '@angular/platform-browser';
Expand All @@ -24,7 +25,13 @@ const CONTENTTYPE_FIELDS: ContenttypeFieldElement[] = [

@NgModule({
declarations: [AppComponent],
imports: [BrowserModule, BrowserAnimationsModule, DotBinaryFieldComponent, MonacoEditorModule],
imports: [
BrowserModule,
BrowserAnimationsModule,
HttpClientModule,
DotBinaryFieldComponent,
MonacoEditorModule
],
providers: [DotMessageService, DotUploadService]
})
export class AppModule implements DoBootstrap {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default {
control: { type: 'select' }
},
type: {
options: ['-', 'p-button-text', 'p-button-outlined'],
options: ['-', 'p-button-text', 'p-button-outlined', 'p-button-link'],
control: { type: 'select' }
},
iconPos: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
class="binary-field__container"
*ngIf="vm$ | async as vm"
[ngClass]="{
'binary-field__container--uploading': vm.status === BINARY_FIELD_STATUS.UPLOADING
'binary-field__container--uploading': vm.status === BinaryFieldStatus.UPLOADING
}">
<div
class="binary-field__drop-zone-container"
*ngIf="vm.status === BINARY_FIELD_STATUS.INIT || vm.status === BINARY_FIELD_STATUS.ERROR"
*ngIf="vm.status === BinaryFieldStatus.INIT"
data-testId="binary-field__drop-zone-container">
<div
class="binary-field__drop-zone"
Expand All @@ -18,10 +18,7 @@
(fileDragLeave)="setDropZoneActiveState(false)"
(fileDropped)="handleFileDrop($event)"
data-testId="dropzone">
<dot-binary-field-ui-message
[message]="vm.UiMessage.message | dm : vm.UiMessage.args"
[icon]="vm.UiMessage.icon"
[severity]="vm.UiMessage.severity">
<dot-binary-field-ui-message [uiMessage]="vm.uiMessage">
<button
class="binary-field__drop-zone-btn"
(click)="openFilePicker()"
Expand All @@ -42,64 +39,60 @@
<div class="binary-field__actions">
<p-button
[label]="'dot.binary.field.action.import.from.url' | dm"
(click)="openDialog(BINARY_FIELD_MODE.URL)"
(click)="openDialog(BinaryFieldMode.URL)"
data-testId="action-url-btn"
styleClass="p-button-link"
icon="pi pi-link"></p-button>
<p-button
[label]="'dot.binary.field.action.create.new.file' | dm"
(click)="openDialog(BINARY_FIELD_MODE.EDITOR)"
(click)="openDialog(BinaryFieldMode.EDITOR)"
data-testId="action-editor-btn"
styleClass="p-button-link"
icon="pi pi-code">
</p-button>
icon="pi pi-code"></p-button>
</div>
</div>

<dot-spinner
*ngIf="vm.status === BINARY_FIELD_STATUS.UPLOADING"
*ngIf="vm.status === BinaryFieldStatus.UPLOADING"
data-testId="loading"></dot-spinner>

<!-- This component is another ticket -->
<div *ngIf="vm.status === BINARY_FIELD_STATUS.PREVIEW" data-testId="preview">
<span>
{{ vm.tempFile.fileName }}
</span>
<br />
<p-button
class="p-button-outlined"
[label]="'dot.binary.field.action.remove' | dm"
(click)="removeFile()"
data-testId="action-remove-btn"
icon="pi pi-trash"></p-button>
</div>
<dot-binary-field-preview
*ngIf="vm.status === BinaryFieldStatus.PREVIEW"
[file]="vm.file"
[editableImage]="vm.isEnterprise"
(removeFile)="removeFile()"
(editFile)="onEditFile()"
(editImage)="onEditImage()"
data-testId="preview"></dot-binary-field-preview>

<p-dialog
[(visible)]="dialogOpen"
[keepInViewport]="false"
[modal]="true"
[header]="dialogHeaderMap[vm.mode] | dm"
[draggable]="false"
[resizable]="false"
[closeOnEscape]="false"
[styleClass]="isEditorMode(vm.mode) ? 'screen-cover' : ''"
(onHide)="afterDialogClose()">
<ng-container [ngSwitch]="vm.mode">
[styleClass]="vm.mode === BinaryFieldMode.EDITOR ? 'screen-cover' : ''">
<ng-container *ngIf="dialogOpen" [ngSwitch]="vm.mode">
<dot-dot-binary-field-url-mode
*ngSwitchCase="BINARY_FIELD_MODE.URL"
*ngSwitchCase="BinaryFieldMode.URL"
[accept]="accept"
[maxFileSize]="maxFileSize"
(tempFileUploaded)="setTempFile($event)"
(cancel)="closeDialog()"
data-testId="url-mode"></dot-dot-binary-field-url-mode>
<dot-dot-binary-field-editor
*ngSwitchCase="BINARY_FIELD_MODE.EDITOR"
*ngSwitchCase="BinaryFieldMode.EDITOR"
[fileName]="vm.file?.name"
[fileContent]="vm.file?.content"
[accept]="accept"
(tempFileUploaded)="setTempFile($event)"
(cancel)="closeDialog()"
data-testId="editor-mode"></dot-dot-binary-field-editor>
</ng-container>
</p-dialog>
</div>

<div class="binary-field__helper" *ngIf="helperText">
<i class="pi pi-info-circle binary-field__helper-icon"></i>
<span data-testId="helper-text">{{ helperText }}</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,37 @@
min-width: 40rem;
min-height: 40rem;
}
p-dialog {
.p-dialog-mask.p-component-overlay {
background-color: transparent;
-webkit-backdrop-filter: blur($blur-md);
backdrop-filter: blur($blur-md);
}
}
}

dot-drop-zone {
height: 100%;
width: 100%;
}

.binary-field__container {
display: flex;
justify-content: center;
align-items: center;
width: 100%;
gap: $spacing-3;
border-radius: $border-radius-md;
border: $field-border-size solid $color-palette-gray-300;
padding: $spacing-1;
margin-bottom: $spacing-1;
height: 10rem;
height: 12.5rem;
min-width: 17.5rem;
}

.binary-field__container--uploading {
border: $field-border-size dashed $color-palette-gray-300;
}

.binary-field__helper-icon {
color: $color-palette-gray-600;
}

.binary-field__helper {
display: flex;
justify-content: flex-start;
Expand All @@ -39,20 +47,24 @@
font-weight: $font-size-sm;
}

.binary-field__helper-icon {
color: $color-palette-gray-600;
}

.binary-field__actions {
display: flex;
flex-direction: column;
gap: $spacing-3;
justify-content: center;
align-items: flex-start;
}

::ng-deep .p-button {
display: inline-flex;
user-select: none;
align-items: center;
vertical-align: bottom;
text-align: center;
}
.binary-field__actions .p-button {
display: inline-flex;
user-select: none;
align-items: center;
vertical-align: bottom;
text-align: center;
}

.binary-field__actions ::ng-deep {
Expand Down Expand Up @@ -82,20 +94,19 @@
justify-content: center;
align-items: center;
border-radius: $border-radius-md;
user-select: none;
cursor: default;
flex-grow: 1;
height: 100%;
}

.binary-field__drop-zone-btn {
border: none;
background: none;
color: $color-palette-primary-500;
text-decoration: underline;
font-size: $font-size-md;
font-family: $font-default;
padding: revert;
}
.binary-field__drop-zone-btn {
border: none;
background: none;
color: $color-palette-primary-500;
text-decoration: underline;
font-size: $font-size-md;
font-family: $font-default;
padding: revert;
}

.binary-field__drop-zone--active {
Expand All @@ -105,11 +116,6 @@
box-shadow: $md-shadow-6;
}

.binary-field__drop-zone dot-drop-zone {
height: 100%;
width: 100%;
}

.binary-field__input {
display: none;
}
Expand All @@ -119,11 +125,3 @@
display: block;
height: 25rem;
}

p-dialog ::ng-deep {
.p-dialog-mask.p-component-overlay {
background-color: transparent;
-webkit-backdrop-filter: blur($blur-md);
backdrop-filter: blur($blur-md);
}
}
Loading
Loading