- Notifications
You must be signed in to change notification settings - Fork3.6k
Angular - Implementing the CMS Kit module features#24234
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Draft
sumeyyeKurtulus wants to merge18 commits intodevChoose a base branch fromissue/cms-kit-angular
base:dev
Could not load branches
Branch not found:{{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline, and old review comments may become outdated.
+56,270 −1
Draft
Changes from1 commit
Commits
Show all changes
18 commits Select commitHold shift + click to select a range
104dcb8 update: add guides
sumeyyeKurtulus10469d4 add: cms kit library skeleton
sumeyyeKurtulus175e64e add: cms kit library proxy
sumeyyeKurtulus89d4d7c add: cms kit library path declarations
sumeyyeKurtulusead7d06 update: proxy imports
sumeyyeKurtulusdff20ff fix: guides
sumeyyeKurtulus67ed01e add: comments feature for the cms kit admin side
sumeyyeKurtulus9f909aa add: tags for the admin side
sumeyyeKurtulus6717280 add: pages structure
sumeyyeKurtulus0c65999 add: common code mirror and toast ui components
sumeyyeKurtulus2e61b5d update: route names for the admin cms kit
sumeyyeKurtulus3b33b62 add: `@toast-ui/editor` and `codemirror` dependencies
sumeyyeKurtulus138742c add: blogs structure for the admin side
sumeyyeKurtulus2704848 add: utils for the cms kit operations
sumeyyeKurtulusb26b686 add: blog posts feature for the admin side
sumeyyeKurtulus363fdf4 update: add cover image and tags
sumeyyeKurtulus64fcb11 add: menu items for the admin side
sumeyyeKurtulus3c587b2 fix: menu item modal component problems
sumeyyeKurtulusFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
add: blog posts feature for the admin side
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
commitb26b68613fe774ae019f08d3e5233211dca96c6a
There are no files selected for viewing
12 changes: 6 additions & 6 deletionsnpm/ng-packs/guides/CMS_KIT_ANGULAR_STRUCTURE.md
This file contains hidden or 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
47 changes: 47 additions & 0 deletionsnpm/ng-packs/packages/cms-kit/admin/src/cms-kit-admin.routes.ts
This file contains hidden or 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
41 changes: 41 additions & 0 deletions...ages/cms-kit/admin/src/components/blog-posts/blog-post-form/blog-post-form.component.html
This file contains hidden or 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,41 @@ | ||
| <abp-page [title]="'CmsKit::BlogPosts' | abpLocalization"> | ||
| <div class="card"> | ||
| <div class="card-body"> | ||
| @if (form && (!isEditMode || blogPost)) { | ||
| <form [formGroup]="form" (ngSubmit)="saveAsDraft()" validateOnSubmit> | ||
| <!-- Basic fields --> | ||
| <abp-extensible-form [selectedRecord]="blogPost || {}" /> | ||
| <!-- Content editor --> | ||
| <div class="mt-3"> | ||
| <label class="form-label">{{ 'CmsKit::Content' | abpLocalization }}</label> | ||
| <abp-toastui-editor formControlName="content" /> | ||
| </div> | ||
| </form> | ||
| } @else { | ||
| <div class="text-center"> | ||
| <i class="fa fa-pulse fa-spinner" aria-hidden="true"></i> | ||
| </div> | ||
| } | ||
| </div> | ||
| <div class="card-footer"> | ||
| <div class="d-flex justify-content-start gap-2"> | ||
| <button class="btn btn-secondary" (click)="saveAsDraft()" [disabled]="form?.invalid"> | ||
| {{ 'CmsKit::SaveAsDraft' | abpLocalization }} | ||
| </button> | ||
| @if (isEditMode) { | ||
| <abp-button (click)="publish()" [disabled]="form?.invalid"> | ||
| {{ 'CmsKit::Publish' | abpLocalization }} | ||
| </abp-button> | ||
| } @else { | ||
| <abp-button (click)="publish()" [disabled]="form?.invalid"> | ||
| {{ 'CmsKit::Publish' | abpLocalization }} | ||
| </abp-button> | ||
| <abp-button (click)="sendToReview()" [disabled]="form?.invalid"> | ||
| {{ 'CmsKit::SendToReviewToPublish' | abpLocalization }} | ||
| </abp-button> | ||
| } | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </abp-page> |
117 changes: 117 additions & 0 deletions...ckages/cms-kit/admin/src/components/blog-posts/blog-post-form/blog-post-form.component.ts
This file contains hidden or 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,117 @@ | ||
| import { Component, OnInit, inject, Injector, DestroyRef } from '@angular/core'; | ||
| import { CommonModule } from '@angular/common'; | ||
| import { ReactiveFormsModule, FormGroup, FormControl } from '@angular/forms'; | ||
| import { ActivatedRoute } from '@angular/router'; | ||
| import { NgxValidateCoreModule } from '@ngx-validate/core'; | ||
| import { LocalizationPipe } from '@abp/ng.core'; | ||
| import { | ||
| ExtensibleFormComponent, | ||
| FormPropData, | ||
| generateFormFromProps, | ||
| EXTENSIONS_IDENTIFIER, | ||
| } from '@abp/ng.components/extensible'; | ||
| import { PageComponent } from '@abp/ng.components/page'; | ||
| import { ButtonComponent } from '@abp/ng.theme.shared'; | ||
| import { ToastuiEditorComponent, prepareSlugFromControl } from '@abp/ng.cms-kit'; | ||
| import { BlogPostAdminService, BlogPostDto } from '@abp/ng.cms-kit/proxy'; | ||
| import { eCmsKitAdminComponents } from '../../../enums'; | ||
| import { BlogPostFormService } from '../../../services'; | ||
| @Component({ | ||
| selector: 'abp-blog-post-form', | ||
| templateUrl: './blog-post-form.component.html', | ||
| providers: [ | ||
| { | ||
| provide: EXTENSIONS_IDENTIFIER, | ||
| useValue: eCmsKitAdminComponents.BlogPostForm, | ||
| }, | ||
| ], | ||
| imports: [ | ||
| ButtonComponent, | ||
| ExtensibleFormComponent, | ||
| PageComponent, | ||
| ToastuiEditorComponent, | ||
| LocalizationPipe, | ||
| ReactiveFormsModule, | ||
| CommonModule, | ||
| NgxValidateCoreModule, | ||
| ], | ||
| }) | ||
| export class BlogPostFormComponent implements OnInit { | ||
| private blogPostService = inject(BlogPostAdminService); | ||
| private injector = inject(Injector); | ||
| private blogPostFormService = inject(BlogPostFormService); | ||
| private route = inject(ActivatedRoute); | ||
| private destroyRef = inject(DestroyRef); | ||
| form: FormGroup; | ||
| blogPost: BlogPostDto | null = null; | ||
| blogPostId: string | null = null; | ||
| isEditMode = false; | ||
| ngOnInit() { | ||
| const id = this.route.snapshot.params['id']; | ||
| if (id) { | ||
| this.isEditMode = true; | ||
| this.blogPostId = id; | ||
| this.loadBlogPost(id); | ||
| } else { | ||
| this.isEditMode = false; | ||
| this.buildForm(); | ||
| } | ||
| } | ||
| private loadBlogPost(id: string) { | ||
| this.blogPostService.get(id).subscribe(blogPost => { | ||
| this.blogPost = blogPost; | ||
| this.buildForm(); | ||
| }); | ||
| } | ||
| private buildForm() { | ||
| const data = new FormPropData(this.injector, this.blogPost || {}); | ||
| const baseForm = generateFormFromProps(data); | ||
| this.form = new FormGroup({ | ||
| ...baseForm.controls, | ||
| content: new FormControl(this.blogPost?.content || ''), | ||
| }); | ||
| prepareSlugFromControl(this.form, 'title', 'slug', this.destroyRef); | ||
| } | ||
| private executeSaveOperation(operation: 'save' | 'draft' | 'publish' | 'sendToReview') { | ||
| if (this.isEditMode) { | ||
| if (!this.blogPost || !this.blogPostId) { | ||
| return; | ||
| } | ||
| this.blogPostFormService.update(this.blogPostId, this.form, this.blogPost).subscribe(); | ||
| return; | ||
| } | ||
| switch (operation) { | ||
| case 'save': | ||
| this.blogPostFormService.createAsDraft(this.form).subscribe(); | ||
| break; | ||
| case 'draft': | ||
| this.blogPostFormService.createAsDraft(this.form).subscribe(); | ||
| break; | ||
| case 'publish': | ||
| this.blogPostFormService.createAndPublish(this.form).subscribe(); | ||
| break; | ||
| case 'sendToReview': | ||
| this.blogPostFormService.createAndSendToReview(this.form).subscribe(); | ||
| break; | ||
| } | ||
| } | ||
| saveAsDraft() { | ||
| this.executeSaveOperation('draft'); | ||
| } | ||
| publish() { | ||
| this.executeSaveOperation('publish'); | ||
| } | ||
| sendToReview() { | ||
| this.executeSaveOperation('sendToReview'); | ||
| } | ||
| } |
40 changes: 40 additions & 0 deletions...ages/cms-kit/admin/src/components/blog-posts/blog-post-list/blog-post-list.component.html
This file contains hidden or 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,40 @@ | ||
| <abp-page [title]="'CmsKit::BlogPosts' | abpLocalization" [toolbar]="data.items"> | ||
| <div class="card mb-4"> | ||
| <div class="card-body"> | ||
| <div class="row"> | ||
| <div class="col-2"> | ||
| <select class="form-select" [(ngModel)]="statusFilter" (change)="onStatusChange()"> | ||
| <option [ngValue]="null">{{ 'CmsKit::AllPosts' | abpLocalization }}</option> | ||
| <option [ngValue]="BlogPostStatus.Draft"> | ||
| {{ 'CmsKit::' + 'CmsKit.BlogPost.Status.0' | abpLocalization }} | ||
| </option> | ||
| <option [ngValue]="BlogPostStatus.Published"> | ||
| {{ 'CmsKit::' + 'CmsKit.BlogPost.Status.1' | abpLocalization }} | ||
| </option> | ||
| <option [ngValue]="BlogPostStatus.WaitingForReview"> | ||
| {{ 'CmsKit::' + 'CmsKit.BlogPost.Status.2' | abpLocalization }} | ||
| </option> | ||
| </select> | ||
| </div> | ||
| <div class="col-10"> | ||
| <div class="input-group"> | ||
| <input | ||
| type="search" | ||
| class="form-control" | ||
| [placeholder]="'AbpUi::PagerSearch' | abpLocalization" | ||
| [(ngModel)]="filter" | ||
| (keyup.enter)="onSearch()" | ||
| /> | ||
| <button class="btn btn-primary" type="button" (click)="onSearch()"> | ||
| <i class="fa fa-search" aria-hidden="true"></i> | ||
| </button> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| <div class="card"> | ||
| <abp-extensible-table [data]="data.items" [recordsTotal]="data.totalCount" [list]="list" /> | ||
| </div> | ||
| </abp-page> |
70 changes: 70 additions & 0 deletions...ckages/cms-kit/admin/src/components/blog-posts/blog-post-list/blog-post-list.component.ts
This file contains hidden or 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,70 @@ | ||
| import { Component, OnInit, inject } from '@angular/core'; | ||
| import { CommonModule } from '@angular/common'; | ||
| import { FormsModule } from '@angular/forms'; | ||
| import { ListService, PagedResultDto, LocalizationPipe } from '@abp/ng.core'; | ||
| import { ExtensibleTableComponent, EXTENSIONS_IDENTIFIER } from '@abp/ng.components/extensible'; | ||
| import { PageComponent } from '@abp/ng.components/page'; | ||
| import { | ||
| BlogPostAdminService, | ||
| BlogPostGetListInput, | ||
| BlogPostListDto, | ||
| BlogPostStatus, | ||
| } from '@abp/ng.cms-kit/proxy'; | ||
| import { eCmsKitAdminComponents } from '../../../enums'; | ||
| @Component({ | ||
| selector: 'abp-blog-post-list', | ||
| templateUrl: './blog-post-list.component.html', | ||
| providers: [ | ||
| ListService, | ||
| { | ||
| provide: EXTENSIONS_IDENTIFIER, | ||
| useValue: eCmsKitAdminComponents.BlogPosts, | ||
| }, | ||
| ], | ||
| imports: [ExtensibleTableComponent, PageComponent, LocalizationPipe, FormsModule, CommonModule], | ||
| }) | ||
| export class BlogPostListComponent implements OnInit { | ||
| data: PagedResultDto<BlogPostListDto> = { items: [], totalCount: 0 }; | ||
| public readonly list = inject(ListService<BlogPostGetListInput>); | ||
| private blogPostService = inject(BlogPostAdminService); | ||
| filter = ''; | ||
| statusFilter: BlogPostStatus | null = null; | ||
| BlogPostStatus = BlogPostStatus; | ||
| ngOnInit() { | ||
| this.hookToQuery(); | ||
| } | ||
| onSearch() { | ||
| this.list.filter = this.filter; | ||
| this.list.get(); | ||
| } | ||
| onStatusChange() { | ||
| this.list.get(); | ||
| } | ||
| private hookToQuery() { | ||
| this.list | ||
| .hookToQuery(query => { | ||
| let filters: Partial<BlogPostGetListInput> = {}; | ||
| if (this.list.filter) { | ||
| filters.filter = this.list.filter; | ||
| } | ||
| if (this.statusFilter !== null) { | ||
| filters.status = this.statusFilter; | ||
| } | ||
| const input: BlogPostGetListInput = { | ||
| ...query, | ||
| ...filters, | ||
| }; | ||
| return this.blogPostService.getList(input); | ||
| }) | ||
| .subscribe(res => { | ||
| this.data = res; | ||
| }); | ||
| } | ||
| } |
2 changes: 2 additions & 0 deletionsnpm/ng-packs/packages/cms-kit/admin/src/components/blog-posts/index.ts
This file contains hidden or 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,2 @@ | ||
| export * from './blog-post-list/blog-post-list.component'; | ||
| export * from './blog-post-form/blog-post-form.component'; |
2 changes: 1 addition & 1 deletionnpm/ng-packs/packages/cms-kit/admin/src/components/index.ts
This file contains hidden or 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.
Uh oh!
There was an error while loading.Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.