Move 'pagination' to the core, barrel files for core

This commit is contained in:
Denys Vuika
2016-07-14 12:04:30 +01:00
parent 6826f796fe
commit 380652df83
24 changed files with 174 additions and 62 deletions

View File

@@ -15,37 +15,20 @@
* limitations under the License.
*/
import { AlfrescoSettingsService } from './src/services/AlfrescoSettingsService.service';
import { AlfrescoTranslationLoader } from './src/services/AlfrescoTranslationLoader.service';
import { AlfrescoTranslationService } from './src/services/AlfrescoTranslationService.service';
import { AlfrescoPipeTranslate } from './src/services/AlfrescoPipeTranslate.service';
import { AlfrescoAuthenticationService } from './src/services/AlfrescoAuthenticationService.service';
import { AlfrescoContentService } from './src/services/AlfrescoContentService.service';
import { ContextMenuService } from './src/services/context-menu.service';
import { ContextMenuHolderComponent } from './src/components/context-menu-holder.component';
import { ContextMenuDirective } from './src/components/context-menu.directive';
import { MDL } from './src/material/MaterialDesignLiteUpgradeElement';
import { AlfrescoMdlButtonDirective } from './src/material/mdl-button.directive';
import { AlfrescoMdlMenuDirective } from './src/material/mdl-menu.directive';
import {
AlfrescoSettingsService,
AlfrescoTranslationLoader,
AlfrescoTranslationService,
AlfrescoPipeTranslate,
AlfrescoAuthenticationService,
AlfrescoContentService
} from './src/services/index';
export * from './src/services/AlfrescoSettingsService.service';
export * from './src/services/AlfrescoTranslationLoader.service';
export * from './src/services/AlfrescoTranslationService.service';
export * from './src/services/AlfrescoPipeTranslate.service';
export * from './src/services/AlfrescoAuthenticationService.service';
export * from './src/services/AlfrescoContentService.service';
import { ContextMenuService } from './src/components/context-menu/context-menu.service';
// Material Design Lite integration
export * from './src/material/MaterialDesignLiteUpgradeElement';
export * from './src/material/mdl-button.directive';
export * from './src/material/mdl-menu.directive';
export * from './src/services/context-menu.service';
export * from './src/components/context-menu-holder.component';
export * from './src/components/context-menu.directive';
export * from './src/data/pagination-provider';
export * from './src/utils/object-utils';
export * from './src/services/index';
export * from './src/components/index';
export * from './src/utils/index';
export const ALFRESCO_CORE_PROVIDERS: [any] = [
AlfrescoAuthenticationService,
@@ -57,17 +40,3 @@ export const ALFRESCO_CORE_PROVIDERS: [any] = [
ContextMenuService
];
export const CONTEXT_MENU_PROVIDERS: [any] = [
ContextMenuService
];
export const CONTEXT_MENU_DIRECTIVES: [any] = [
ContextMenuHolderComponent,
ContextMenuDirective
];
export const MATERIAL_DESIGN_DIRECTIVES: [any] = [
MDL,
AlfrescoMdlButtonDirective,
AlfrescoMdlMenuDirective
];

View File

@@ -6,13 +6,14 @@
"scripts": {
"clean": "rimraf dist node_modules typings",
"typings": "typings install",
"build": "npm run tslint && typings install && rimraf dist && tsc && license-check",
"build": "npm run tslint && typings install && rimraf dist && tsc && npm run copy-static && license-check",
"build:w": "npm run tslint && typings install && rimraf dist && npm run watch-task",
"watch-task": "concurrently \"npm run tsc:w\" \"license-check\"",
"tslint": "npm run tslint-src && npm run tslint-root",
"tslint-src": "tslint -c tslint.json src/{,**/}**.ts",
"tslint-root": "tslint -c tslint.json *.ts",
"licensecheck": "license-check",
"copy-static": "cpx \"./src/**/*.{html,css}\" ./dist/src",
"tsc": "tsc",
"tsc:w": "tsc -w",
"pretest": "npm run build",

View File

@@ -16,7 +16,7 @@
*/
import { describe, it, beforeEach } from '@angular/core/testing';
import { ContextMenuService } from './../services/context-menu.service';
import { ContextMenuService } from './context-menu.service';
import { ContextMenuHolderComponent } from './context-menu-holder.component';
describe('ContextMenuHolderComponent', () => {

View File

@@ -16,7 +16,7 @@
*/
import { Component, HostListener } from '@angular/core';
import { ContextMenuService } from './../services/context-menu.service';
import { ContextMenuService } from './context-menu.service';
@Component({
selector:'context-menu-holder',

View File

@@ -17,7 +17,7 @@
import { describe, it, beforeEach } from '@angular/core/testing';
import { ContextMenuDirective } from './context-menu.directive';
import { ContextMenuService } from './../services/context-menu.service';
import { ContextMenuService } from './context-menu.service';
describe('ContextMenuDirective', () => {

View File

@@ -16,7 +16,7 @@
*/
import { Directive, Input, HostListener } from '@angular/core';
import { ContextMenuService } from './../services/context-menu.service';
import { ContextMenuService } from './context-menu.service';
@Directive({
selector:'[context-menu]'

View File

@@ -0,0 +1,33 @@
/*!
* @license
* Copyright 2016 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { ContextMenuService } from './context-menu.service';
import { ContextMenuHolderComponent } from './context-menu-holder.component';
import { ContextMenuDirective } from './context-menu.directive';
export * from './context-menu.service';
export * from './context-menu-holder.component';
export * from './context-menu.directive';
export const CONTEXT_MENU_PROVIDERS: [any] = [
ContextMenuService
];
export const CONTEXT_MENU_DIRECTIVES: [any] = [
ContextMenuHolderComponent,
ContextMenuDirective
];

View File

@@ -0,0 +1,20 @@
/*!
* @license
* Copyright 2016 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export * from './context-menu/index';
export * from './material/index';
export * from './pagination/index';

View File

@@ -0,0 +1,30 @@
/*!
* @license
* Copyright 2016 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { MDL } from './MaterialDesignLiteUpgradeElement';
import { AlfrescoMdlButtonDirective } from './mdl-button.directive';
import { AlfrescoMdlMenuDirective } from './mdl-menu.directive';
export * from './MaterialDesignLiteUpgradeElement';
export * from './mdl-button.directive';
export * from './mdl-menu.directive';
export const MATERIAL_DESIGN_DIRECTIVES: [any] = [
MDL,
AlfrescoMdlButtonDirective,
AlfrescoMdlMenuDirective
];

View File

@@ -0,0 +1,19 @@
/*!
* @license
* Copyright 2016 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export * from './pagination-provider';
export * from './pagination.component';

View File

@@ -0,0 +1,64 @@
.mdl-paging {
color: rgba(0, 0, 0, 0.54);
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-justify-content: flex-end;
-ms-flex-pack: end;
justify-content: flex-end;
-webkit-align-items: center;
-ms-flex-align: center;
align-items: center;
height: 56px;
-webkit-flex-flow: row wrap;
-ms-flex-flow: row wrap;
flex-flow: row wrap;
}
.mdl-paging > * {
-webkit-flex: none;
-ms-flex: none;
flex: none;
}
.mdl-list + .mdl-paging {
margin: 0;
}
.mdl-paging__per-page {
position: relative;
}
.mdl-paging__per-page-label {
margin-right: 40px;
}
.mdl-paging__per-page-value {
position: absolute;
right: 36px;
top: 6px;
}
.mdl-paging__per-page + .mdl-paging__count {
margin-left: 24px;
}
.mdl-paging .mdl-menu {
min-width: 64px;
}
.mdl-paging__prev:last-child {
margin-right: 44px;
}
.mdl-paging__count + .mdl-paging__prev {
margin-left: 24px;
}
.mdl-paging__prev + .mdl-paging__next {
margin-left: 12px;
}
.mdl-paging__count + .mdl-paging__next {
margin-left: 68px;
}

View File

@@ -0,0 +1,27 @@
<div *ngIf="provider" class="mdl-paging">
<span class="mdl-paging__per-page">
<span class="mdl-paging__per-page-label">Rows per page:</span>
<span class="mdl-paging__per-page-value">{{pageSize}}</span>
<button alfresco-mdl-button id="pageSizePicker" class="mdl-button--icon mdl-paging__per-page-dropdown">
<i class="material-icons">arrow_drop_down</i>
</button>
<ul alfresco-mdl-menu for="pageSizePicker" class="mdl-menu--bottom-right">
<li *ngFor="let size of supportedPageSizes"
tabindex="-1" [attr.data-value]="size" class="mdl-menu__item"
(click)="setPageSize(size)">
<span>{{size}}</span>
</li>
</ul>
</span>
<span class="mdl-paging__count">{{summary}}</span>
<button (click)="showPrevPage()"
[disabled]="!prevPageAvail"
alfresco-mdl-button class="mdl-button--icon mdl-paging__prev">
<i class="material-icons">keyboard_arrow_left</i>
</button>
<button (click)="showNextPage()"
[disabled]="!nextPageAvail"
alfresco-mdl-button class="mdl-button--icon mdl-paging__next">
<i class="material-icons">keyboard_arrow_right</i>
</button>
</div>

View File

@@ -0,0 +1,86 @@
/*!
* @license
* Copyright 2016 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Component, Input } from '@angular/core';
import { MATERIAL_DESIGN_DIRECTIVES } from './../material/index';
import { PaginationProvider } from './pagination-provider';
declare let __moduleName: string;
@Component({
moduleId: __moduleName,
selector: 'alfresco-pagination',
templateUrl: './pagination.component.html',
styleUrls: ['./pagination.component.css'],
directives: [MATERIAL_DESIGN_DIRECTIVES]
})
export class PaginationComponent {
DEFAULT_PAGE_SIZE: number = 20;
@Input()
supportedPageSizes: number[] = [5, 10, 20, 50, 100];
@Input()
provider: PaginationProvider;
get pageSize(): number {
if (this.provider) {
return this.provider.maxItems;
}
return this.DEFAULT_PAGE_SIZE;
}
set pageSize(value: number) {
if (this.provider) {
this.provider.maxItems = value;
}
}
setPageSize(value: number) {
this.pageSize = value;
}
get summary(): string {
let from = this.provider.skipCount;
if (from === 0) {
from = 1;
}
let to = this.provider.skipCount + this.provider.count;
let of = this.provider.totalItems;
return `${from}-${to} of ${of}`;
}
get nextPageAvail(): boolean {
return this.provider.hasMoreItems;
}
get prevPageAvail(): boolean {
return this.provider.skipCount > 0;
}
showNextPage() {
this.provider.skipCount += this.provider.maxItems;
}
showPrevPage() {
this.provider.skipCount -= this.provider.maxItems;
}
}

View File

@@ -0,0 +1,23 @@
/*!
* @license
* Copyright 2016 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export * from './AlfrescoSettingsService.service';
export * from './AlfrescoTranslationLoader.service';
export * from './AlfrescoTranslationService.service';
export * from './AlfrescoPipeTranslate.service';
export * from './AlfrescoAuthenticationService.service';
export * from './AlfrescoContentService.service';

View File

@@ -0,0 +1,18 @@
/*!
* @license
* Copyright 2016 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export * from './object-utils';