mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-3223] Restore message directive files fix (#3499)
* fix restore notification * improve path specification property * fix lint and document issues * fix test * remove unused import
This commit is contained in:
@@ -17,7 +17,7 @@
|
|||||||
<button
|
<button
|
||||||
mat-icon-button
|
mat-icon-button
|
||||||
(selection-node-restored)="refresh()"
|
(selection-node-restored)="refresh()"
|
||||||
(restore)="documentList.reload()"
|
(restore)="onRestore($event)"
|
||||||
[adf-restore]="documentList.selection"
|
[adf-restore]="documentList.selection"
|
||||||
*ngIf="documentList.selection.length"
|
*ngIf="documentList.selection.length"
|
||||||
title="{{ 'TRASHCAN.ACTIONS.RESTORE' | translate }}">
|
title="{{ 'TRASHCAN.ACTIONS.RESTORE' | translate }}">
|
||||||
|
@@ -25,34 +25,57 @@
|
|||||||
|
|
||||||
import { Component, ViewChild } from '@angular/core';
|
import { Component, ViewChild } from '@angular/core';
|
||||||
import { DocumentListComponent } from '@alfresco/adf-content-services';
|
import { DocumentListComponent } from '@alfresco/adf-content-services';
|
||||||
import { UserPreferencesService, UserPreferenceValues } from '@alfresco/adf-core';
|
import { UserPreferencesService, UserPreferenceValues, RestoreMessageModel, NotificationService } from '@alfresco/adf-core';
|
||||||
|
import { Router } from '@angular/router';
|
||||||
|
import { PathInfoEntity } from 'alfresco-js-api';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
templateUrl: './trashcan.component.html',
|
templateUrl: './trashcan.component.html',
|
||||||
styleUrls: ['trashcan.component.scss']
|
styleUrls: ['trashcan.component.scss']
|
||||||
})
|
})
|
||||||
export class TrashcanComponent {
|
export class TrashcanComponent {
|
||||||
|
|
||||||
@ViewChild('documentList')
|
@ViewChild('documentList')
|
||||||
documentList: DocumentListComponent;
|
documentList: DocumentListComponent;
|
||||||
|
|
||||||
supportedPages = [];
|
supportedPages = [];
|
||||||
currentLocale;
|
currentLocale;
|
||||||
|
|
||||||
constructor(private preference: UserPreferencesService) {
|
constructor(
|
||||||
this.preference.select(UserPreferenceValues.SupportedPageSizes)
|
private preference: UserPreferencesService,
|
||||||
.subscribe((pages) => {
|
private router: Router,
|
||||||
this.supportedPages = pages;
|
private notificationService: NotificationService
|
||||||
});
|
) {
|
||||||
|
this.preference
|
||||||
|
.select(UserPreferenceValues.SupportedPageSizes)
|
||||||
|
.subscribe(pages => {
|
||||||
|
this.supportedPages = pages;
|
||||||
|
});
|
||||||
|
|
||||||
this.preference.select(UserPreferenceValues.Locale).subscribe((locale) => {
|
this.preference
|
||||||
this.currentLocale = locale;
|
.select(UserPreferenceValues.Locale)
|
||||||
});
|
.subscribe(locale => {
|
||||||
|
this.currentLocale = locale;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
onRestore(restoreMessage: RestoreMessageModel) {
|
||||||
|
this.notificationService
|
||||||
|
.openSnackMessageAction(
|
||||||
|
restoreMessage.message,
|
||||||
|
restoreMessage.action
|
||||||
|
)
|
||||||
|
.onAction()
|
||||||
|
.subscribe(() => this.navigateLocation(restoreMessage.path));
|
||||||
|
this.documentList.reload();
|
||||||
|
}
|
||||||
|
|
||||||
|
private navigateLocation(path: PathInfoEntity) {
|
||||||
|
const parent = path.elements[path.elements.length - 1];
|
||||||
|
this.router.navigate(['files/', parent.id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
refresh() {
|
refresh() {
|
||||||
this.documentList.reload();
|
this.documentList.reload();
|
||||||
this.documentList.resetSelection();
|
this.documentList.resetSelection();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -15,7 +15,7 @@ Restores deleted nodes to their original location.
|
|||||||
<button mat-icon-button
|
<button mat-icon-button
|
||||||
location="/files"
|
location="/files"
|
||||||
[adf-restore]="documentList.selection"
|
[adf-restore]="documentList.selection"
|
||||||
(restore)="documentList.reload()">
|
(restore)="onRestore($event)">
|
||||||
<mat-icon>restore</mat-icon>
|
<mat-icon>restore</mat-icon>
|
||||||
</button>
|
</button>
|
||||||
</adf-toolbar>
|
</adf-toolbar>
|
||||||
@@ -26,20 +26,38 @@ Restores deleted nodes to their original location.
|
|||||||
</adf-document-list>
|
</adf-document-list>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
```ts
|
||||||
|
onRestore(restoreMessage: RestoreMessageModel) {
|
||||||
|
this.notificationService
|
||||||
|
.openSnackMessageAction(
|
||||||
|
restoreMessage.message,
|
||||||
|
restoreMessage.action
|
||||||
|
)
|
||||||
|
.onAction()
|
||||||
|
.subscribe(() => this.navigateLocation(restoreMessage.path));
|
||||||
|
this.documentList.reload();
|
||||||
|
}
|
||||||
|
|
||||||
|
navigateLocation(path: PathInfoEntity) {
|
||||||
|
const parent = path.elements[path.elements.length - 1];
|
||||||
|
this.router.navigate(['files/', parent.id]);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
## Class members
|
## Class members
|
||||||
|
|
||||||
### Properties
|
### Properties
|
||||||
|
|
||||||
| Name | Type | Default value | Description |
|
| Name | Type | Default value | Description |
|
||||||
| -- | -- | -- | -- |
|
| -- | -- | -- | -- |
|
||||||
| location | `string` | "" | Path to restored node. |
|
| location | `string` | "" | **Deprecated:** 2.4.0 Path to restored node. |
|
||||||
| adf-restore | `DeletedNodeEntry[]` | | Array of deleted nodes to restore. |
|
| adf-restore | `DeletedNodeEntry[]` | | Array of deleted nodes to restore. |
|
||||||
|
|
||||||
### Events
|
### Events
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| -- | -- | -- |
|
| -- | -- | -- |
|
||||||
| restore | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<any>` | Emitted when restoration is complete. |
|
| restore | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<`[`RestoreMessageModel`](../../lib/core/directives/node-restore.directive.ts)`>` | Emitted when restoration is complete. |
|
||||||
|
|
||||||
## Details
|
## Details
|
||||||
|
|
||||||
|
@@ -18,7 +18,7 @@
|
|||||||
/* tslint:disable:component-selector no-input-rename */
|
/* tslint:disable:component-selector no-input-rename */
|
||||||
|
|
||||||
import { Directive, EventEmitter, HostListener, Input, Output } from '@angular/core';
|
import { Directive, EventEmitter, HostListener, Input, Output } from '@angular/core';
|
||||||
import { DeletedNodeEntry, DeletedNodesPaging } from 'alfresco-js-api';
|
import { DeletedNodeEntry, DeletedNodesPaging, PathInfoEntity } from 'alfresco-js-api';
|
||||||
import { Observable } from 'rxjs/Observable';
|
import { Observable } from 'rxjs/Observable';
|
||||||
import { AlfrescoApiService } from '../services/alfresco-api.service';
|
import { AlfrescoApiService } from '../services/alfresco-api.service';
|
||||||
import { TranslationService } from '../services/translation.service';
|
import { TranslationService } from '../services/translation.service';
|
||||||
@@ -26,6 +26,12 @@ import 'rxjs/add/observable/from';
|
|||||||
import 'rxjs/add/observable/zip';
|
import 'rxjs/add/observable/zip';
|
||||||
import 'rxjs/add/operator/mergeMap';
|
import 'rxjs/add/operator/mergeMap';
|
||||||
|
|
||||||
|
export class RestoreMessageModel {
|
||||||
|
message: string;
|
||||||
|
path: PathInfoEntity;
|
||||||
|
action: string;
|
||||||
|
}
|
||||||
|
|
||||||
@Directive({
|
@Directive({
|
||||||
selector: '[adf-restore]'
|
selector: '[adf-restore]'
|
||||||
})
|
})
|
||||||
@@ -36,13 +42,13 @@ export class NodeRestoreDirective {
|
|||||||
@Input('adf-restore')
|
@Input('adf-restore')
|
||||||
selection: DeletedNodeEntry[];
|
selection: DeletedNodeEntry[];
|
||||||
|
|
||||||
/** Path to restored node. */
|
/** @deprecated 2.4.0 Path to restored node. */
|
||||||
@Input()
|
@Input()
|
||||||
location: string = '';
|
location: string = '';
|
||||||
|
|
||||||
/** Emitted when restoration is complete. */
|
/** Emitted when restoration is complete. */
|
||||||
@Output()
|
@Output()
|
||||||
restore: EventEmitter<any> = new EventEmitter();
|
restore: EventEmitter<RestoreMessageModel> = new EventEmitter();
|
||||||
|
|
||||||
@HostListener('click')
|
@HostListener('click')
|
||||||
onClick() {
|
onClick() {
|
||||||
@@ -243,7 +249,15 @@ export class NodeRestoreDirective {
|
|||||||
|
|
||||||
const action = (status.oneSucceeded && !status.someFailed) ? this.translation.instant('CORE.RESTORE_NODE.VIEW') : '';
|
const action = (status.oneSucceeded && !status.someFailed) ? this.translation.instant('CORE.RESTORE_NODE.VIEW') : '';
|
||||||
|
|
||||||
this.restore.emit({ message: message, action: action });
|
let path;
|
||||||
|
if (status.success && status.success.length > 0) {
|
||||||
|
path = status.success[0].entry.path;
|
||||||
|
}
|
||||||
|
this.restore.emit({
|
||||||
|
message: message,
|
||||||
|
action: action,
|
||||||
|
path: path
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private reset(): void {
|
private reset(): void {
|
||||||
|
@@ -104,7 +104,7 @@ function aggPhase(aggData) {
|
|||||||
|
|
||||||
var libName = adfLibNames[l];
|
var libName = adfLibNames[l];
|
||||||
var libSection = sections[libName];
|
var libSection = sections[libName];
|
||||||
|
|
||||||
var md = makeLibSectionMD(libSection, false);
|
var md = makeLibSectionMD(libSection, false);
|
||||||
|
|
||||||
zone(indexFileTree, libName, (startComment, oldSection, endComment) => {
|
zone(indexFileTree, libName, (startComment, oldSection, endComment) => {
|
||||||
@@ -164,14 +164,14 @@ function updatePhase(tree, pathname, aggData) {
|
|||||||
|
|
||||||
|
|
||||||
// Create a stoplist of regular expressions.
|
// Create a stoplist of regular expressions.
|
||||||
function makeStoplist(config) {
|
function makeStoplist(config) {
|
||||||
var listExpressions = config.undocStoplist;
|
var listExpressions = config.undocStoplist;
|
||||||
var result = [];
|
var result = [];
|
||||||
|
|
||||||
for (var i = 0; i < listExpressions.length; i++) {
|
for (var i = 0; i < listExpressions.length; i++) {
|
||||||
result.push(new RegExp(listExpressions[i]));
|
result.push(new RegExp(listExpressions[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -182,7 +182,7 @@ function rejectItemViaStoplist(stoplist, itemName) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -216,11 +216,13 @@ function prepareIndexSections(aggData) {
|
|||||||
"status": status
|
"status": status
|
||||||
});
|
});
|
||||||
} else if (!rejectItemViaStoplist(aggData.stoplist, itemName)) {
|
} else if (!rejectItemViaStoplist(aggData.stoplist, itemName)) {
|
||||||
|
if(sections[libName]){
|
||||||
sections[libName][srcData.type].undocumented.push({
|
sections[libName][srcData.type].undocumented.push({
|
||||||
"displayName": displayName,
|
"displayName": displayName,
|
||||||
"mdName": itemName + ".md",
|
"mdName": itemName + ".md",
|
||||||
"srcPath": srcData.path
|
"srcPath": srcData.path
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -248,9 +250,9 @@ function initEmptySections() {
|
|||||||
|
|
||||||
function buildMDDocumentedTable(docItems, forSubFolder) {
|
function buildMDDocumentedTable(docItems, forSubFolder) {
|
||||||
var rows = [
|
var rows = [
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
for (var i = 0; i < docItems.length; i++) {
|
for (var i = 0; i < docItems.length; i++) {
|
||||||
rows.push(makeMDDocumentedTableRow(docItems[i], forSubFolder));
|
rows.push(makeMDDocumentedTableRow(docItems[i], forSubFolder));
|
||||||
}
|
}
|
||||||
@@ -262,9 +264,9 @@ function buildMDDocumentedTable(docItems, forSubFolder) {
|
|||||||
|
|
||||||
function buildMDUndocumentedTable(docItems, forSubFolder) {
|
function buildMDUndocumentedTable(docItems, forSubFolder) {
|
||||||
var rows = [
|
var rows = [
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
for (var i = 0; i < docItems.length; i++) {
|
for (var i = 0; i < docItems.length; i++) {
|
||||||
rows.push(makeMDUndocumentedTableRow(docItems[i], forSubFolder));
|
rows.push(makeMDUndocumentedTableRow(docItems[i], forSubFolder));
|
||||||
}
|
}
|
||||||
@@ -361,7 +363,7 @@ function makeLibSectionMD(libSection, forSubFolder){
|
|||||||
var md = [];
|
var md = [];
|
||||||
|
|
||||||
var libClassTypes = Object.keys(libSection);
|
var libClassTypes = Object.keys(libSection);
|
||||||
|
|
||||||
for (var i = 0; i < libClassTypes.length; i++) {
|
for (var i = 0; i < libClassTypes.length; i++) {
|
||||||
var classType = libClassTypes[i];
|
var classType = libClassTypes[i];
|
||||||
|
|
||||||
@@ -375,7 +377,7 @@ function makeLibSectionMD(libSection, forSubFolder){
|
|||||||
if ((classSection.documented.length > 0) || (classSection.undocumented.length > 0)) {
|
if ((classSection.documented.length > 0) || (classSection.undocumented.length > 0)) {
|
||||||
displayNameNode = unist.makeText(ngHelpers.dekebabifyName(classType + "s"));
|
displayNameNode = unist.makeText(ngHelpers.dekebabifyName(classType + "s"));
|
||||||
md.push(unist.makeHeading(displayNameNode, 2));
|
md.push(unist.makeHeading(displayNameNode, 2));
|
||||||
|
|
||||||
var tableRows = [
|
var tableRows = [
|
||||||
unist.makeTableRow([
|
unist.makeTableRow([
|
||||||
unist.makeTableCell([unist.makeText("Name")]),
|
unist.makeTableCell([unist.makeText("Name")]),
|
||||||
@@ -421,4 +423,4 @@ function buildGuideSection(guideJsonFilename, forSubFolder) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return unist.makeListUnordered(listItems);
|
return unist.makeListUnordered(listItems);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user