Skip to content

Commit

Permalink
fix commerrceproductquantities
Browse files Browse the repository at this point in the history
  • Loading branch information
nikiquickie committed Nov 28, 2024
1 parent 579608d commit 71c72ad
Show file tree
Hide file tree
Showing 20 changed files with 391 additions and 5 deletions.
10 changes: 10 additions & 0 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,16 @@ const routes: Routes = [
component: UserComponent,
children: [
/* user */
{
path: 'commercecontents',
canActivate: [MetaGuard],
data: {
meta: {
title: 'Commercecontents'
}
},
loadChildren: () => import('./modules/commercecontent/pages/commercecontents/commercecontents.module').then(m => m.CommercecontentsModule)
},
{
path: 'commerceproductquantities',
canActivate: [MetaGuard],
Expand Down
10 changes: 10 additions & 0 deletions src/app/core/theme/user/user.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@
<span class="material-icons">store</span>
<span translate>Theme.Stores</span>
</a>
<a [routerLinkActiveOptions]="{ exact: true }" routerLinkActive="_activeLink" routerLink="/"
class="nav__burger-link" (click)="hideSidebar()">
<span class="material-icons">people</span>
<span translate>Theme.Clients</span>
</a>
<a [routerLinkActiveOptions]="{ exact: true }" routerLinkActive="_activeLink"
routerLink="/commercewarehouses" class="nav__burger-link" (click)="hideSidebar()">
<span class="material-icons">home</span>
Expand All @@ -84,6 +89,11 @@
<span class="material-icons">photo_camera</span>
<span translate>Theme.Portfolios</span>
</a>
<a [routerLinkActiveOptions]="{ exact: true }" routerLinkActive="_activeLink"
routerLink="/commercecontents" class="nav__burger-link" (click)="hideSidebar()">
<span class="material-icons">content_paste</span>
<span translate>Theme.Contents</span>
</a>
<a [routerLinkActiveOptions]="{ exact: true }" routerLinkActive="_activeLink" routerLink="/commercetags"
class="nav__burger-link" (click)="hideSidebar()">
<span class="material-icons">style</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ export class CommercesComponent {
return '/commerceportfolios/' + doc._id;
}
},
{
icon: 'content_paste',
hrefFunc: (doc: Commerce): string => {
return '/commercecontents/' + doc._id;
}
},
{
icon: 'style',
hrefFunc: (doc: Commerce): string => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ import { CommercebrandsComponent } from './commercebrands.component';
import { Routes, RouterModule } from '@angular/router';

const routes: Routes = [
{
path: '',
component: CommercebrandsComponent
},
{
path: ':commerce_id',
component: CommercebrandsComponent
Expand Down
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',
}
]
}
]
}
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;
}
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.
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);
}
}
}
});
};
}
}
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 {}
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>
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;
}
}
}
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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ export class CommerceproductsComponent {
});
},
buttons: [
{
icon: '1x_mobiledata',
hrefFunc: (doc: Commerceproduct): string => {
return '/commerceproductquantities/' + doc._id;
}
},
{
icon: 'cloud_download',
click: (doc: Commerceproduct): void => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@ import { CrudDocument } from 'wacom';
export interface Commerceproductquantity extends CrudDocument {
name: string;
description: string;
commerceproduct: string;
commercestore: string;
commercewarehouse: string;
}
Loading

0 comments on commit 71c72ad

Please sign in to comment.