-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
579608d
commit 71c72ad
Showing
20 changed files
with
391 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/app/modules/commercecontent/formcomponents/commercecontent.formcomponents.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
export const commercecontentFormComponents = { | ||
formId: 'commercecontent', | ||
title: 'Commercecontent', | ||
components: [ | ||
{ | ||
name: 'Text', | ||
key: 'name', | ||
focused: true, | ||
fields: [ | ||
{ | ||
name: 'Placeholder', | ||
value: 'fill commercecontent title', | ||
}, | ||
{ | ||
name: 'Label', | ||
value: 'Title', | ||
} | ||
] | ||
}, | ||
{ | ||
name: 'Text', | ||
key: 'description', | ||
fields: [ | ||
{ | ||
name: 'Placeholder', | ||
value: 'fill commercecontent description', | ||
}, | ||
{ | ||
name: 'Label', | ||
value: 'Description', | ||
} | ||
] | ||
} | ||
] | ||
} |
7 changes: 7 additions & 0 deletions
7
src/app/modules/commercecontent/interfaces/commercecontent.interface.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { CrudDocument } from 'wacom'; | ||
|
||
export interface Commercecontent extends CrudDocument { | ||
name: string; | ||
description: string; | ||
commerce: string; | ||
} |
6 changes: 6 additions & 0 deletions
6
src/app/modules/commercecontent/pages/commercecontents/commercecontents.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<wtable | ||
title="Commercecontents" | ||
[columns]="columns" | ||
[config]="config" | ||
[rows]="rows" | ||
></wtable> |
Empty file.
142 changes: 142 additions & 0 deletions
142
src/app/modules/commercecontent/pages/commercecontents/commercecontents.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
import { Component } from '@angular/core'; | ||
import { AlertService, CoreService } from 'wacom'; | ||
import { CommercecontentService } from '../../services/commercecontent.service'; | ||
import { Commercecontent } from '../../interfaces/commercecontent.interface'; | ||
import { FormService } from 'src/app/core/modules/form/form.service'; | ||
import { TranslateService } from 'src/app/core/modules/translate/translate.service'; | ||
import { FormInterface } from 'src/app/core/modules/form/interfaces/form.interface'; | ||
import { commercecontentFormComponents } from '../../formcomponents/commercecontent.formcomponents'; | ||
import { Router } from '@angular/router'; | ||
|
||
@Component({ | ||
templateUrl: './commercecontents.component.html', | ||
styleUrls: ['./commercecontents.component.scss'], | ||
standalone: false | ||
}) | ||
export class CommercecontentsComponent { | ||
columns = ['name', 'description']; | ||
|
||
commerce = this._router.url.includes('/commercebrands/') | ||
? this._router.url.replace('/commercebrands/', '') | ||
: ''; | ||
|
||
form: FormInterface = this._form.getForm('commercecontent', commercecontentFormComponents); | ||
|
||
config = { | ||
create: (): void => { | ||
this._form.modal<Commercecontent>(this.form, { | ||
label: 'Create', | ||
click: (created: unknown, close: () => void) => { | ||
if (this.commerce) { | ||
(created as Commercecontent).commerce = this.commerce; | ||
} | ||
this._commercecontentService.create(created as Commercecontent); | ||
|
||
close(); | ||
} | ||
}); | ||
}, | ||
update: (doc: Commercecontent): void => { | ||
this._form.modal<Commercecontent>(this.form, [], doc).then((updated: Commercecontent) => { | ||
this._core.copy(updated, doc); | ||
|
||
this._commercecontentService.update(doc); | ||
}); | ||
}, | ||
delete: (doc: Commercecontent): void => { | ||
this._alert.question({ | ||
text: this._translate.translate( | ||
'Common.Are you sure you want to delete this commercecontent?' | ||
), | ||
buttons: [ | ||
{ | ||
text: this._translate.translate('Common.No') | ||
}, | ||
{ | ||
text: this._translate.translate('Common.Yes'), | ||
callback: (): void => { | ||
this._commercecontentService.delete(doc); | ||
} | ||
} | ||
] | ||
}); | ||
}, | ||
buttons: [ | ||
{ | ||
icon: 'cloud_download', | ||
click: (doc: Commercecontent): void => { | ||
this._form.modalUnique<Commercecontent>('commercecontent', 'url', doc); | ||
} | ||
} | ||
], | ||
headerButtons: [ | ||
{ | ||
icon: 'playlist_add', | ||
click: this._bulkManagement(), | ||
class: 'playlist', | ||
}, | ||
{ | ||
icon: 'edit_note', | ||
click: this._bulkManagement(false), | ||
class: 'edit', | ||
}, | ||
] | ||
}; | ||
|
||
get rows(): Commercecontent[] { | ||
return this._commercecontentService.commercecontents; | ||
} | ||
|
||
constructor( | ||
private _translate: TranslateService, | ||
private _commercecontentService: CommercecontentService, | ||
private _alert: AlertService, | ||
private _form: FormService, | ||
private _core: CoreService, | ||
private _router: Router | ||
) {} | ||
|
||
private _bulkManagement(create = true): () => void { | ||
return (): void => { | ||
this._form | ||
.modalDocs<Commercecontent>(create ? [] : this.rows) | ||
.then((commercecontents: Commercecontent[]) => { | ||
if (create) { | ||
for (const commercecontent of commercecontents) { | ||
if (this.commerce) { | ||
commercecontent.commerce = this.commerce; | ||
} | ||
this._commercecontentService.create(commercecontent); | ||
} | ||
} else { | ||
for (const commercecontent of this.rows) { | ||
if (!commercecontents.find( | ||
localCommercecontent => localCommercecontent._id === commercecontent._id | ||
)) { | ||
this._commercecontentService.delete(commercecontent); | ||
} | ||
} | ||
|
||
for (const commercecontent of commercecontents) { | ||
const localCommercecontent = this.rows.find( | ||
localCommercecontent => localCommercecontent._id === commercecontent._id | ||
); | ||
|
||
if (localCommercecontent) { | ||
this._core.copy(commercecontent, localCommercecontent); | ||
|
||
this._commercecontentService.update(localCommercecontent); | ||
} else { | ||
if (this.commerce) { | ||
commercecontent.commerce = this.commerce; | ||
} | ||
commercecontent.__created = false; | ||
|
||
this._commercecontentService.create(commercecontent); | ||
} | ||
} | ||
} | ||
}); | ||
}; | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/app/modules/commercecontent/pages/commercecontents/commercecontents.module.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { CoreModule } from 'src/app/core/core.module'; | ||
import { CommercecontentsComponent } from './commercecontents.component'; | ||
import { Routes, RouterModule } from '@angular/router'; | ||
|
||
const routes: Routes = [ | ||
{ | ||
path: '', | ||
component: CommercecontentsComponent | ||
}, | ||
{ | ||
path: ':commerce_id', | ||
component: CommercecontentsComponent | ||
} | ||
]; | ||
|
||
@NgModule({ | ||
imports: [RouterModule.forChild(routes), CoreModule], | ||
declarations: [CommercecontentsComponent], | ||
providers: [] | ||
}) | ||
export class CommercecontentsModule {} |
6 changes: 6 additions & 0 deletions
6
...modules/commercecontent/selectors/commercecontent/commercecontent-selector.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<wselect | ||
(modelChange)="onChange.emit($event)" | ||
placeholder="Select commercecontent" | ||
[select]="value" | ||
[items]="items" | ||
></wselect> |
Empty file.
35 changes: 35 additions & 0 deletions
35
...p/modules/commercecontent/selectors/commercecontent/commercecontent-selector.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { | ||
SimpleChanges, | ||
EventEmitter, | ||
Component, | ||
OnChanges, | ||
Output, | ||
Input | ||
} from '@angular/core'; | ||
import { SelectModule } from 'src/app/core/modules/select/select.module'; | ||
import { CommercecontentService } from '../../services/commercecontent.service'; | ||
import { Commercecontent } from '../../interfaces/commercecontent.interface'; | ||
|
||
@Component({ | ||
selector: 'commercecontent-selector', | ||
templateUrl: './commercecontent-selector.component.html', | ||
styleUrls: ['./commercecontent-selector.component.scss'], | ||
imports: [SelectModule] | ||
}) | ||
export class SelectUserComponent implements OnChanges { | ||
@Input() value: string; | ||
|
||
@Output() wChange = new EventEmitter(); | ||
|
||
get items(): Commercecontent[] { | ||
return this._commercecontentService.commercecontents; | ||
} | ||
|
||
constructor(private _commercecontentService: CommercecontentService) {} | ||
|
||
ngOnChanges(changes: SimpleChanges): void { | ||
if (changes['value'] && !changes['value'].firstChange) { | ||
this.value = changes['value'].currentValue; | ||
} | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
src/app/modules/commercecontent/services/commercecontent.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { Commercecontent } from '../interfaces/commercecontent.interface'; | ||
import { | ||
AlertService, | ||
CoreService, | ||
HttpService, | ||
StoreService, | ||
CrudService | ||
} from 'wacom'; | ||
|
||
@Injectable({ | ||
providedIn: 'root', | ||
}) | ||
export class CommercecontentService extends CrudService<Commercecontent> { | ||
commercecontents: Commercecontent[] = this.getDocs(); | ||
|
||
commercecontentsByAuthor: Record<string, Commercecontent[]> = {}; | ||
|
||
constructor( | ||
_http: HttpService, | ||
_store: StoreService, | ||
_alert: AlertService, | ||
_core: CoreService | ||
) { | ||
super( | ||
{ | ||
name: 'commercecontent', | ||
}, | ||
_http, | ||
_store, | ||
_alert, | ||
_core | ||
); | ||
|
||
this.get(); | ||
|
||
this.filteredDocuments(this.commercecontentsByAuthor); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.