Skip to content

Commit

Permalink
fix: better naming conventions for uploaded files #77
Browse files Browse the repository at this point in the history
  • Loading branch information
flauc committed Feb 11, 2022
1 parent 79350aa commit bac1942
Show file tree
Hide file tree
Showing 16 changed files with 76 additions and 23 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"dev:fields-mat": "ng build fields-mat --configuration=development --watch",
"dev:segments-mat": "ng build segments-mat --configuration=development --watch",
"dev:page-builder": "ng build page-builder --configuration=development --watch",
"dev:tinymce": "ng build tinymce --configuration=development --watch",
"build:form-builder": "ng build form-builder && cp ./README.md ./dist/@jaspero/form-builder && cp LICENSE ./dist/@jaspero/form-builder",
"build:fields-mat": "ng build fields-mat && cp ./README.md ./dist/@jaspero/fb-fields-mat && cp LICENSE ./dist/@jaspero/fb-fields-mat",
"build:segments-mat": "ng build segments-mat && cp ./README.md ./dist/@jaspero/fb-segments-mat && cp LICENSE ./dist/@jaspero/fb-segments-mat",
Expand Down Expand Up @@ -44,7 +45,7 @@
"@jaspero/fb-form-ui": "2.4.7",
"@jaspero/fb-page-builder": "3.17.1",
"@jaspero/fb-segments-mat": "file:projects/segments-mat",
"@jaspero/fb-tinymce": "2.4.5",
"@jaspero/fb-tinymce": "file:projects/tinymce",
"@jaspero/form-builder": "file:projects/form-builder",
"@jaspero/ng-helpers": "5.2.0",
"@jaspero/utils": "1.7.0",
Expand Down
6 changes: 3 additions & 3 deletions projects/fields-mat/src/lib/fields/file/file.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export class FileComponent extends FieldComponent<FileData> implements OnInit {
const current = window.jpFb.exists(data);

if (!current.exists || !window.jpFb.change(data)) {
return of();
return of(true);
}

if (current.value && typeof current.value !== 'string') {
Expand All @@ -111,7 +111,7 @@ export class FileComponent extends FieldComponent<FileData> implements OnInit {
* Maybe we should put a type extension based on type
* instead of taking from the name
*/
name += (current.value.name.split('.')[1]);;
name += '.' + (current.value.name.split('.')[1]);;
}

return from(
Expand All @@ -129,7 +129,7 @@ export class FileComponent extends FieldComponent<FileData> implements OnInit {
);
}

return of();
return of(true);
}
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,15 @@ export class GalleryComponent extends FieldComponent<GalleryData> implements OnI
const current = window.jpFb.exists(data);

if (!current.exists) {
return of();
return of(true);
}

if (
!data.cData.toRemove.length &&
!current.value ||
!current.value.find((val: any) => !val.live)
) {
return of();
return of(true);
}

return forkJoin([
Expand All @@ -154,7 +154,7 @@ export class GalleryComponent extends FieldComponent<GalleryData> implements OnI
* Maybe we should put a type extension based on type
* instead of taking from the name
*/
name += (current.value.name.split('.')[1]);;
name += '.' + (cur.pushToLive.name.split('.')[1]);;
}

acc.push(
Expand Down
6 changes: 3 additions & 3 deletions projects/fields-mat/src/lib/fields/image/image.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export class ImageComponent extends FieldComponent<ImageData> implements OnInit
const current = window.jpFb.exists(data);

if (!current.exists || !window.jpFb.change(data)) {
return of();
return of(true);
}

if (current.value && typeof current.value !== 'string') {
Expand All @@ -124,7 +124,7 @@ export class ImageComponent extends FieldComponent<ImageData> implements OnInit
* Maybe we should put a type extension based on type
* instead of taking from the name
*/
name += (current.value.name.split('.')[1]);;
name += '.' + (current.value.name.split('.')[1]);;
}

return from(
Expand All @@ -144,7 +144,7 @@ export class ImageComponent extends FieldComponent<ImageData> implements OnInit
);
}

return of();
return of(true);
}
});
}
Expand Down
2 changes: 2 additions & 0 deletions projects/form-builder/src/lib/form-builder.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ export class FormBuilderComponent implements OnChanges, OnDestroy {
.sort((p1, p2) => p1[1].priority - p2[1].priority)
.filter(process => process[1].save);

console.log(processes);

if (!processes.length) {
return of(data);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,12 @@ export class BackgroundComponent extends ImageComponent implements OnInit {
const current = window.jpFb.exists(data);

if (!current.exists) {
return of();
return of(true);
}

if (this.color.value) {
set(data.outputValue, data.pointer, this.imageUrl.value);
return of();
return of(true);
}

if (current.value && typeof current.value !== 'string') {
Expand All @@ -172,7 +172,7 @@ export class BackgroundComponent extends ImageComponent implements OnInit {
* Maybe we should put a type extension based on type
* instead of taking from the name
*/
name += (current.value.name.split('.')[1]);;
name += '.' + (current.value.name.split('.')[1]);;
}

return from(
Expand All @@ -192,7 +192,7 @@ export class BackgroundComponent extends ImageComponent implements OnInit {
);
}

return of();
return of(true);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ export class PageBuilderComponent extends FieldComponent<BlocksData> implements
}
}))
);
return of();
return of(true);
}
})
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {DefinitionWithConfiguration} from '@jaspero/form-builder/public-api';
import {DefinitionWithConfiguration} from '@jaspero/form-builder';
import {TemplateEditorConfig} from '../template-editor.component';

export type TemplateEditorDefinition = DefinitionWithConfiguration<TemplateEditorConfig, '', 'template-editor'>
2 changes: 1 addition & 1 deletion projects/tinymce/src/lib/tinymce/tinymce-definition.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {DefinitionWithConfiguration} from '@jaspero/form-builder/public-api';
import {DefinitionWithConfiguration} from '@jaspero/form-builder';
import {TinyConfiguration} from './tinymce.component';

export type TinymceDefinition = DefinitionWithConfiguration<TinyConfiguration, '', 'tinymce'>
4 changes: 2 additions & 2 deletions projects/tinymce/src/lib/tinymce/tinymce.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export class TinymceComponent extends FieldComponent<TinyData>
const current = window.jpFb.exists(data);

if (!current.exists || !window.jpFb.change(data)) {
return of();
return of(true);
}

if (this.imageReplacements.length) {
Expand Down Expand Up @@ -166,7 +166,7 @@ export class TinymceComponent extends FieldComponent<TinyData>
}
}

return of();
return of(true);
}
})
}
Expand Down
2 changes: 2 additions & 0 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {ExampleCustomComponent} from './example-custom/example-custom.component'
import {MockDbService} from './mock/mock-db.service';
import {MockStorageService} from './mock/mock-storage.service';
import {translocoLoader} from './transloco.loader';
import {TinymceModule} from '@jaspero/fb-tinymce';

const routes: Routes = [
{
Expand All @@ -43,6 +44,7 @@ const routes: Routes = [
HttpClientModule,
RouterModule.forRoot(routes),
TranslocoModule,
TinymceModule,
FormBuilderModule.forRoot(),
FbFieldsMatModule.forRoot({prefix: ''}),
FbSegmentsMatModule.forRoot({prefix: ''}),
Expand Down
4 changes: 2 additions & 2 deletions src/app/examples/core/core.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {AfterViewInit, ChangeDetectionStrategy, Component, QueryList, ViewChildren} from '@angular/core';
import {FormBuilderComponent} from '@jaspero/form-builder';
import {EXAMPLE_TWO} from './forms/example-two';
import {SAVE_METHOD_EXAMPLE} from './forms/save-method-example';

@Component({
selector: 'sc-core',
Expand All @@ -13,7 +13,7 @@ export class CoreComponent implements AfterViewInit {
@ViewChildren(FormBuilderComponent)
formComponents: QueryList<FormBuilderComponent>;

form = EXAMPLE_TWO;
form = SAVE_METHOD_EXAMPLE;

ngAfterViewInit() {
this.formComponents.forEach(log => {
Expand Down
45 changes: 45 additions & 0 deletions src/app/examples/core/forms/save-method-example.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import {FormBuilderData} from '../../../../../projects/form-builder/src/lib/interfaces/form-builder-data.interface';

export const SAVE_METHOD_EXAMPLE: FormBuilderData = {
schema: {
properties: {
file: {type: 'string'},
image: {type: 'string'},
gallery: {type: 'array'},
tiny: {type: 'string'}
}
},
definitions: {
image: {
component: {
type: 'image'
}
},
file: {
component: {
type: 'file'
}
},
gallery: {
component: {
type: 'gallery'
}
},
tiny: {
component: {
type: 'tinymce'
}
}
},
segments: [
{
type: 'empty',
fields: [
'/file',
'/image',
'/tiny',
'/gallery'
]
}
]
};
2 changes: 1 addition & 1 deletion src/app/mock/mock-storage.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export class MockStorageService implements StorageService {
upload(path: string, data: any, metadata?: any): any {
return Promise.resolve({
ref: {
getDownloadURL: () => Promise.resolve('https://jaspero.co')
getDownloadURL: () => Promise.resolve('https://jaspero.co/' + path)
}
});
}
Expand Down
3 changes: 3 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
],
"@jaspero/monaco-editor": [
"dist/monaco-editor"
],
"@jaspero/fb-tinymce": [
"dist/tinymce"
]
}
},
Expand Down

0 comments on commit bac1942

Please sign in to comment.