mirror of https://github.com/abpframework/abp.git
18 changed files with 228 additions and 335 deletions
@ -0,0 +1,3 @@ |
|||||
|
export interface Settings { |
||||
|
commentRequireApprovement: boolean; |
||||
|
} |
||||
@ -0,0 +1 @@ |
|||||
|
export * from './cms-kit-admin-settings'; |
||||
@ -1,6 +1,10 @@ |
|||||
import { makeEnvironmentProviders } from '@angular/core'; |
import { makeEnvironmentProviders } from '@angular/core'; |
||||
import { CMS_KIT_ADMIN_ROUTE_PROVIDERS } from './route.provider'; |
import { CMS_KIT_ADMIN_ROUTE_PROVIDERS } from './route.provider'; |
||||
|
import { CMS_KIT_ADMIN_SETTING_TAB_PROVIDERS } from './setting-tab.provider'; |
||||
|
|
||||
export function provideCmsKitAdminConfig() { |
export function provideCmsKitAdminConfig() { |
||||
return makeEnvironmentProviders([CMS_KIT_ADMIN_ROUTE_PROVIDERS]); |
return makeEnvironmentProviders([ |
||||
|
CMS_KIT_ADMIN_ROUTE_PROVIDERS, |
||||
|
CMS_KIT_ADMIN_SETTING_TAB_PROVIDERS, |
||||
|
]); |
||||
} |
} |
||||
|
|||||
@ -1,2 +1,3 @@ |
|||||
export * from './cms-kit-admin-config.provider'; |
export * from './cms-kit-admin-config.provider'; |
||||
export * from './route.provider'; |
export * from './route.provider'; |
||||
|
export * from './setting-tab.provider'; |
||||
|
|||||
@ -0,0 +1,27 @@ |
|||||
|
import { ABP, ConfigStateService } from '@abp/ng.core'; |
||||
|
import { SettingTabsService } from '@abp/ng.setting-management/config'; |
||||
|
import { inject, provideAppInitializer } from '@angular/core'; |
||||
|
import { eCmsKitAdminPolicyNames, eCmsKitAdminRouteNames } from '../enums'; |
||||
|
import { CmsSettingsComponent } from '@abp/ng.cms-kit/admin'; |
||||
|
|
||||
|
export const CMS_KIT_ADMIN_SETTING_TAB_PROVIDERS = [ |
||||
|
provideAppInitializer(() => { |
||||
|
configureSettingTabs(); |
||||
|
}), |
||||
|
]; |
||||
|
|
||||
|
export async function configureSettingTabs() { |
||||
|
const settingTabs = inject(SettingTabsService); |
||||
|
const configState = inject(ConfigStateService); |
||||
|
const tabsArray: ABP.Tab[] = [ |
||||
|
{ |
||||
|
name: eCmsKitAdminRouteNames.Cms, |
||||
|
order: 100, |
||||
|
requiredPolicy: eCmsKitAdminPolicyNames.Cms, |
||||
|
invisible: configState.getFeature('CmsKit.CommentEnable')?.toLowerCase() === 'true', |
||||
|
component: CmsSettingsComponent, |
||||
|
}, |
||||
|
]; |
||||
|
|
||||
|
settingTabs.add(tabsArray); |
||||
|
} |
||||
@ -1,2 +1,3 @@ |
|||||
export * from './enums'; |
export * from './enums'; |
||||
export * from './providers'; |
export * from './providers'; |
||||
|
export * from './models'; |
||||
|
|||||
@ -0,0 +1,42 @@ |
|||||
|
<div id="CmsSettingsForm" class="row"> |
||||
|
<div class="col-md-12"> |
||||
|
<ul ngbNav #nav="ngbNav" class="nav-tabs"> |
||||
|
<!-- Comments --> |
||||
|
<li ngbNavItem> |
||||
|
<a ngbNavLink>{{ 'CmsKit::CmsKit:Comment' | abpLocalization }}</a> |
||||
|
<ng-template ngbNavContent> |
||||
|
<div class="abp-md-form"> |
||||
|
<div (keyup.enter)="submit()"> |
||||
|
<div class="mt-3"> |
||||
|
<div class="form-check mb-2"> |
||||
|
<input |
||||
|
class="form-check-input" |
||||
|
[formControl]="commentApprovalControl" |
||||
|
type="checkbox" |
||||
|
id="AccountCMSSettings_EnableCommentApproval" |
||||
|
[checked]="commentApprovalControl.value" |
||||
|
(input)="commentApprovalControl.setValue($event.target.checked)" |
||||
|
/> |
||||
|
<label class="form-check-label" for="AccountCMSSettings_EnableCommentApproval"> |
||||
|
{{ 'CmsKit::CmsKitCommentOptions:RequireApprovement' | abpLocalization }} |
||||
|
</label> |
||||
|
<br /> |
||||
|
<small class="form-text text-muted">{{ |
||||
|
'CmsKit::CmsKitCommentOptions:RequireApprovementDescription' | abpLocalization |
||||
|
}}</small> |
||||
|
</div> |
||||
|
</div> |
||||
|
<hr class="my-3" /> |
||||
|
<div> |
||||
|
<abp-button (click)="submit()" iconClass="fa fa-save" [loading]="loading"> |
||||
|
{{ 'AbpAccount::Save' | abpLocalization }} |
||||
|
</abp-button> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
</ng-template> |
||||
|
</li> |
||||
|
</ul> |
||||
|
<div [ngbNavOutlet]="nav"></div> |
||||
|
</div> |
||||
|
</div> |
||||
@ -0,0 +1,59 @@ |
|||||
|
import { ChangeDetectionStrategy, Component, inject } from '@angular/core'; |
||||
|
import { FormControl, ReactiveFormsModule } from '@angular/forms'; |
||||
|
import { |
||||
|
NgbNav, |
||||
|
NgbNavItem, |
||||
|
NgbNavItemRole, |
||||
|
NgbNavLink, |
||||
|
NgbNavLinkBase, |
||||
|
NgbNavContent, |
||||
|
NgbNavOutlet, |
||||
|
} from '@ng-bootstrap/ng-bootstrap'; |
||||
|
import { finalize } from 'rxjs/operators'; |
||||
|
import { ConfigStateService, LocalizationPipe } from '@abp/ng.core'; |
||||
|
import { ButtonComponent, ToasterService } from '@abp/ng.theme.shared'; |
||||
|
import { CommentAdminService } from '@abp/ng.cms-kit/proxy'; |
||||
|
|
||||
|
import { CMS_KIT_COMMENTS_REQUIRE_APPROVEMENT } from '../comments'; |
||||
|
|
||||
|
@Component({ |
||||
|
selector: 'abp-cms-settings', |
||||
|
templateUrl: './cms-settings.component.html', |
||||
|
changeDetection: ChangeDetectionStrategy.OnPush, |
||||
|
imports: [ |
||||
|
NgbNav, |
||||
|
NgbNavItem, |
||||
|
NgbNavItemRole, |
||||
|
NgbNavLink, |
||||
|
NgbNavLinkBase, |
||||
|
NgbNavContent, |
||||
|
NgbNavOutlet, |
||||
|
LocalizationPipe, |
||||
|
ButtonComponent, |
||||
|
ReactiveFormsModule, |
||||
|
], |
||||
|
}) |
||||
|
export class CmsSettingsComponent { |
||||
|
readonly commentAdminService = inject(CommentAdminService); |
||||
|
readonly configState = inject(ConfigStateService); |
||||
|
readonly toaster = inject(ToasterService); |
||||
|
|
||||
|
commentApprovalControl = new FormControl(false); |
||||
|
|
||||
|
ngOnInit() { |
||||
|
const isCommentApprovalEnabled = |
||||
|
this.configState.getSetting(CMS_KIT_COMMENTS_REQUIRE_APPROVEMENT).toLowerCase() === 'true'; |
||||
|
this.commentApprovalControl.setValue(isCommentApprovalEnabled); |
||||
|
} |
||||
|
|
||||
|
submit() { |
||||
|
this.commentAdminService |
||||
|
.updateSettings({ commentRequireApprovement: this.commentApprovalControl.value }) |
||||
|
.pipe( |
||||
|
finalize(() => { |
||||
|
this.configState.refreshAppState().subscribe(); |
||||
|
}), |
||||
|
) |
||||
|
.subscribe(() => this.toaster.success('AbpUi::SavedSuccessfully', null)); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1 @@ |
|||||
|
export * from './cms-settings.component'; |
||||
@ -1,72 +0,0 @@ |
|||||
<abp-page [title]="'CmsKit::Comments' | abpLocalization"> |
|
||||
<div class="card mb-4"> |
|
||||
<div class="card-body"> |
|
||||
<form [formGroup]="filterForm" (ngSubmit)="onFilter()"> |
|
||||
<div class="row align-items-end"> |
|
||||
<div class="col-lg-4 col-md-12"> |
|
||||
<div class="row"> |
|
||||
<div class="col-lg-6 col-md-6"> |
|
||||
<div class="mb-3"> |
|
||||
<label class="form-label" for="creationStartDate"> |
|
||||
{{ 'CmsKit::StartDate' | abpLocalization }} |
|
||||
</label> |
|
||||
<input |
|
||||
id="creationStartDate" |
|
||||
formControlName="creationStartDate" |
|
||||
class="form-control" |
|
||||
ngbDatepicker |
|
||||
#startDatePicker="ngbDatepicker" |
|
||||
(click)="startDatePicker.toggle()" |
|
||||
readonly |
|
||||
/> |
|
||||
</div> |
|
||||
</div> |
|
||||
<div class="col-lg-6 col-md-6"> |
|
||||
<div class="mb-3"> |
|
||||
<label class="form-label" for="creationEndDate"> |
|
||||
{{ 'CmsKit::EndDate' | abpLocalization }} |
|
||||
</label> |
|
||||
<input |
|
||||
id="creationEndDate" |
|
||||
formControlName="creationEndDate" |
|
||||
class="form-control" |
|
||||
ngbDatepicker |
|
||||
#endDatePicker="ngbDatepicker" |
|
||||
(click)="endDatePicker.toggle()" |
|
||||
readonly |
|
||||
/> |
|
||||
</div> |
|
||||
</div> |
|
||||
</div> |
|
||||
</div> |
|
||||
|
|
||||
<div class="col-lg-3 col-md-6"> |
|
||||
<abp-form-input |
|
||||
formControlName="author" |
|
||||
[label]="'CmsKit::Username' | abpLocalization" |
|
||||
type="text" |
|
||||
/> |
|
||||
</div> |
|
||||
|
|
||||
<div class="col-lg-3 col-md-6"> |
|
||||
<abp-form-input |
|
||||
formControlName="entityType" |
|
||||
[label]="'CmsKit::EntityType' | abpLocalization" |
|
||||
type="text" |
|
||||
/> |
|
||||
</div> |
|
||||
|
|
||||
<div class="col-lg-2 col-md-6"> |
|
||||
<abp-button class="w-100 mb-3" buttonType="Primary" type="submit"> |
|
||||
<i class="fa fa-search" aria-hidden="true"></i> |
|
||||
</abp-button> |
|
||||
</div> |
|
||||
</div> |
|
||||
</form> |
|
||||
</div> |
|
||||
</div> |
|
||||
|
|
||||
<div class="card"> |
|
||||
<abp-extensible-table [data]="data.items" [recordsTotal]="data.totalCount" [list]="list" /> |
|
||||
</div> |
|
||||
</abp-page> |
|
||||
@ -1,122 +0,0 @@ |
|||||
import { Component, OnInit, inject, LOCALE_ID } from '@angular/core'; |
|
||||
import { CommonModule, formatDate } from '@angular/common'; |
|
||||
import { FormBuilder, FormGroup, ReactiveFormsModule } from '@angular/forms'; |
|
||||
import { NgbDatepickerModule } from '@ng-bootstrap/ng-bootstrap'; |
|
||||
import { ListService, LocalizationPipe, PagedResultDto } from '@abp/ng.core'; |
|
||||
import { ExtensibleTableComponent, EXTENSIONS_IDENTIFIER } from '@abp/ng.components/extensible'; |
|
||||
import { PageComponent } from '@abp/ng.components/page'; |
|
||||
import { ButtonComponent, FormInputComponent } from '@abp/ng.theme.shared'; |
|
||||
import { |
|
||||
CommentAdminService, |
|
||||
CommentGetListInput, |
|
||||
CommentWithAuthorDto, |
|
||||
CommentApproveState, |
|
||||
} from '@abp/ng.cms-kit/proxy'; |
|
||||
import { eCmsKitAdminComponents } from '../../../enums'; |
|
||||
|
|
||||
@Component({ |
|
||||
selector: 'abp-comment-approve', |
|
||||
templateUrl: './comment-approve.component.html', |
|
||||
providers: [ |
|
||||
ListService, |
|
||||
{ |
|
||||
provide: EXTENSIONS_IDENTIFIER, |
|
||||
useValue: eCmsKitAdminComponents.CommentApprove, |
|
||||
}, |
|
||||
], |
|
||||
imports: [ |
|
||||
ReactiveFormsModule, |
|
||||
NgbDatepickerModule, |
|
||||
CommonModule, |
|
||||
PageComponent, |
|
||||
ButtonComponent, |
|
||||
FormInputComponent, |
|
||||
LocalizationPipe, |
|
||||
ExtensibleTableComponent, |
|
||||
], |
|
||||
}) |
|
||||
export class CommentApproveComponent implements OnInit { |
|
||||
data: PagedResultDto<CommentWithAuthorDto> = { items: [], totalCount: 0 }; |
|
||||
|
|
||||
public readonly list = inject(ListService<CommentGetListInput>); |
|
||||
private commentService = inject(CommentAdminService); |
|
||||
private fb = inject(FormBuilder); |
|
||||
private locale = inject(LOCALE_ID); |
|
||||
|
|
||||
filterForm!: FormGroup; |
|
||||
|
|
||||
ngOnInit() { |
|
||||
this.createFilterForm(); |
|
||||
this.hookToQuery(); |
|
||||
} |
|
||||
|
|
||||
private createFilterForm() { |
|
||||
this.filterForm = this.fb.group({ |
|
||||
creationStartDate: [null], |
|
||||
creationEndDate: [null], |
|
||||
author: [''], |
|
||||
entityType: [''], |
|
||||
}); |
|
||||
} |
|
||||
|
|
||||
onFilter() { |
|
||||
const formValue = this.filterForm.value; |
|
||||
const filters: Partial<CommentGetListInput> = { |
|
||||
author: formValue.author || undefined, |
|
||||
entityType: formValue.entityType || undefined, |
|
||||
commentApproveState: CommentApproveState.Waiting, |
|
||||
}; |
|
||||
|
|
||||
if (formValue.creationStartDate) { |
|
||||
filters.creationStartDate = this.formatDateForApi(formValue.creationStartDate); |
|
||||
} |
|
||||
|
|
||||
if (formValue.creationEndDate) { |
|
||||
filters.creationEndDate = this.formatDateForApi(formValue.creationEndDate); |
|
||||
} |
|
||||
|
|
||||
this.list.filter = JSON.stringify(filters); |
|
||||
this.list.get(); |
|
||||
} |
|
||||
|
|
||||
private formatDateForApi(date: any): string { |
|
||||
if (!date) { |
|
||||
return ''; |
|
||||
} |
|
||||
|
|
||||
if (typeof date === 'string') { |
|
||||
return date; |
|
||||
} |
|
||||
|
|
||||
if (date.year && date.month && date.day) { |
|
||||
const jsDate = new Date(date.year, date.month - 1, date.day); |
|
||||
return formatDate(jsDate, 'yyyy-MM-dd', this.locale); |
|
||||
} |
|
||||
|
|
||||
return ''; |
|
||||
} |
|
||||
|
|
||||
private hookToQuery() { |
|
||||
this.list |
|
||||
.hookToQuery(query => { |
|
||||
let filters: Partial<CommentGetListInput> = { |
|
||||
commentApproveState: CommentApproveState.Waiting, |
|
||||
}; |
|
||||
if (this.list.filter) { |
|
||||
try { |
|
||||
filters = { ...filters, ...JSON.parse(this.list.filter) }; |
|
||||
} catch { |
|
||||
// Ignore parse errors, use default filters
|
|
||||
} |
|
||||
} |
|
||||
const input: CommentGetListInput = { |
|
||||
...query, |
|
||||
...filters, |
|
||||
}; |
|
||||
return this.commentService.getList(input); |
|
||||
}) |
|
||||
.subscribe(res => { |
|
||||
this.data = res; |
|
||||
}); |
|
||||
} |
|
||||
} |
|
||||
@ -1,4 +1,3 @@ |
|||||
export * from './comment-list/comment-list.component'; |
export * from './comment-list/comment-list.component'; |
||||
export * from './comment-approve/comment-approve.component'; |
|
||||
export * from './comment-details/comment-details.component'; |
export * from './comment-details/comment-details.component'; |
||||
export * from './constants'; |
export * from './constants'; |
||||
|
|||||
Loading…
Reference in new issue