@acpaas-ui/ngx-agenda 中文文档教程

发布于 3年前 浏览 9 更新于 3年前

@acpaas-ui/ngx-agenda

@acpaas-ui/agenda 模块提供了aui-agenda 组件,可以作为日历显示事件。 目前该组件只能显示月视图。

Installation

npm install @acpaas-ui/agenda --save

app.module.ts 中导入组件

import { AgendaModule } from '@acpaas-ui/agenda';

@NgModule({
    imports: [
        AgendaModule
    ]
})

Translation

可以通过forChild 函数翻译月份和星期几标签。

注意日期顺序: 0 = 星期日,1 = 星期一,2 = 星期二,... 6 = 星期六 0 = 一月,1 = 二月,... 11 = 十二月

@NgModule({
    imports: [
        AgendaModule.forChild(
            ['zondag', 'maandag', 'dinsdag', 'woensdag', 'donderdag', 'vrijdag', 'zaterdag'],
            ['januari', 'februari', 'maart', 'april', 'mei', 'juni', 'juli', 'augustus', 'september', 'oktober', 'november', 'december'],
        ),
    ]
})

Basic Usage

最基本的示例是只呈现当前日期的议程。

<aui-agenda
    [activeDate]="activeDate"
    [view]="'MONTH'"
></aui-agenda>

activeDate: Date 当前日期。 示例:“2018-01-10”将打开一月份的月视图。 “2018-02-20”将开启2月份的月视图。

view: string 活动视图。 目前,只有 MONTH 视图可用。

Define startday of week

可以定义哪一天是一周的第一天。 用数字定义日期(0 = 星期日,1 = 星期一,...)或使用 DAYS 枚举:(DAYS.MONDAY 计算结果为 1)import { DAYS } from @acpaas-ui/agenda

<aui-agenda
    [startDayOfWeek]="0"
></aui-agenda>

Display events

<aui-agenda
    ...
    [events]="events"
></aui-agenda>

events: Event[] 事件列表。 一个事件应该至少有一个 startDate, endDate 和 'title.

Display events: template (only for month view)

可以在月视图中为事件项定义模板。

<ng-template #itemTemplate let-event="event">
    <aui-icon name="ai-calendar-3"></aui-icon> {{event.title}}
</ng-template>

<aui-agenda
    ...
    [events]="events"
    [monthEventItemTemplate]="itemTemplate"
></aui-agenda>

使用 ng-template 定义模板,使用 monthEventItemTemplateaui-agenda 上定义。 在模板中,可以使用 let-event="event" 获取事件数据。

在议程中导航有一个回调。 示例:从一月导航到二月,返回值为{ start: "2018-01-29...", end: "2018-03-4..."}。 该值包含月视图的第一天和最后一天。 请注意,第一天和最后一天取决于配置的 startDayOfWeek 属性。

<aui-agenda
    ...
    [events]="events"
    (navigate)="onNavigate($event)"
></aui-agenda>

Select day

单击一天有一个回调。 返回值是所选日期(独立于时区)的 YYYY-MM-DD 格式的字符串。

<aui-agenda
    ...
    (selectDay)="onSelectDay($event)"
></aui-agenda>

Click on "more items" (month view)

当一天的事件多于槽时,aui-agenda 将显示一个带有点击回调的“更多”按钮。 返回值是所选日期的 Date

<aui-agenda
    ...
    (clickMore)="onClickMore($event)"
></aui-agenda>

Agenda size (month view)

aui-agenda 组件的样式基于父容器的可用宽度。 在侧边栏中使用该组件应该会自动呈现 aui-agenda 的小版本。 全屏呈现 aui-agenda 应该在桌面上呈现大版本,在小屏幕上呈现小版本。

@acpaas-ui/ngx-agenda

The @acpaas-ui/agenda module provides the aui-agenda component which can be used as a calendar to display events. At the moment the component can only display a month view.

Installation

npm install @acpaas-ui/agenda --save

Import component in app.module.ts

import { AgendaModule } from '@acpaas-ui/agenda';

@NgModule({
    imports: [
        AgendaModule
    ]
})

Translation

It is possible to translate month and weekday labels through the forChild function.

Mind the order of the days: 0 = sunday, 1 = monday, 2 = tuesday, … 6 = saturday 0 = January, 1 = February, … 11 = December

@NgModule({
    imports: [
        AgendaModule.forChild(
            ['zondag', 'maandag', 'dinsdag', 'woensdag', 'donderdag', 'vrijdag', 'zaterdag'],
            ['januari', 'februari', 'maart', 'april', 'mei', 'juni', 'juli', 'augustus', 'september', 'oktober', 'november', 'december'],
        ),
    ]
})

Basic Usage

The most basic example is to render just the agenda for the current date.

<aui-agenda
    [activeDate]="activeDate"
    [view]="'MONTH'"
></aui-agenda>

activeDate: Date the current date. Example: "2018-01-10" will open the month view on January. "2018-02-20" will open the month view on February.

view: string the active view. For now, only the MONTH view is available.

Define startday of week

It's possible to define which day is the first day of the week. Define the day with a number (0 = sunday, 1 = monday, …) or use the DAYS enum: (DAYS.MONDAY evaluates to 1) import { DAYS } from @acpaas-ui/agenda.

<aui-agenda
    [startDayOfWeek]="0"
></aui-agenda>

Display events

<aui-agenda
    ...
    [events]="events"
></aui-agenda>

events: Event[] A list of events. An event should have at least a startDate, endDate and 'title.

Display events: template (only for month view)

It's possible to define a template for the event-item in the month view.

<ng-template #itemTemplate let-event="event">
    <aui-icon name="ai-calendar-3"></aui-icon> {{event.title}}
</ng-template>

<aui-agenda
    ...
    [events]="events"
    [monthEventItemTemplate]="itemTemplate"
></aui-agenda>

Define a template with ng-template and define on aui-agenda with monthEventItemTemplate. In the template it is possible to get the event data with let-event="event".

There is a callback for navigating in the agenda. Example: when navigating from January to February, the returned value is { start: "2018-01-29...", end: "2018-03-4..."}. This value contains the first and last day of the month view. Be aware that the first and last day are dependant on the configured startDayOfWeek property.

<aui-agenda
    ...
    [events]="events"
    (navigate)="onNavigate($event)"
></aui-agenda>

Select day

There is a callback for clicking on a day. The returned value is a string in YYYY-MM-DD format of the selected day (timezone independent).

<aui-agenda
    ...
    (selectDay)="onSelectDay($event)"
></aui-agenda>

Click on "more items" (month view)

When there are more events than slots for one day, the aui-agenda will display a "more" button with a click callback. The returned value is the Date of the selected day.

<aui-agenda
    ...
    (clickMore)="onClickMore($event)"
></aui-agenda>

Agenda size (month view)

The aui-agenda component is styled based on the available width of the parent container. Using the component in a sidebar should automaticly render the small version of the aui-agenda. Rendering the aui-agenda full-screen should render the big version on desktop and the small version on a small screen.

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文