Переглянути джерело

Move `FilterFileBrowserModel` to model.ts

Frederic Collonval 6 роки тому
батько
коміт
9cf7caa593

+ 45 - 1
packages/filebrowser/src/model.ts

@@ -23,7 +23,8 @@ import {
   find,
   IIterator,
   IterableOrArrayLike,
-  ArrayExt
+  ArrayExt,
+  filter
 } from '@phosphor/algorithm';
 
 import { PromiseDelegate, ReadonlyJSONObject } from '@phosphor/coreutils';
@@ -672,6 +673,49 @@ export namespace FileBrowserModel {
   }
 }
 
+/**
+ * File browser model with optional filter on element.
+ */
+export class FilterFileBrowserModel extends FileBrowserModel {
+  constructor(options: FilterFileBrowserModel.IOptions) {
+    super(options);
+
+    this._filter = options.filter ? options.filter : model => true;
+  }
+
+  /**
+   * Create an iterator over the filtered model's items.
+   *
+   * @returns A new iterator over the model's items.
+   */
+  items(): IIterator<Contents.IModel> {
+    return filter(super.items(), (value, index) => {
+      if (value.type === 'directory') {
+        return true;
+      } else {
+        return this._filter(value);
+      }
+    });
+  }
+
+  private _filter: (value: Contents.IModel) => boolean;
+}
+
+/**
+ * Namespace for the filtered file browser model
+ */
+export namespace FilterFileBrowserModel {
+  /**
+   * Constructor options
+   */
+  export interface IOptions extends FileBrowserModel.IOptions {
+    /**
+     * Filter function on file browser item model
+     */
+    filter?: (value: Contents.IModel) => boolean;
+  }
+}
+
 /**
  * The namespace for the file browser model private data.
  */

+ 3 - 46
packages/filebrowser/src/opendialog.ts

@@ -1,7 +1,7 @@
 // Copyright (c) Jupyter Development Team.
 // Distributed under the terms of the Modified BSD License.
 
-import { filter, IIterator, toArray } from '@phosphor/algorithm';
+import { toArray } from '@phosphor/algorithm';
 import { PanelLayout, Widget } from '@phosphor/widgets';
 import { PathExt } from '@jupyterlab/coreutils';
 
@@ -10,8 +10,8 @@ import { IDocumentManager } from '@jupyterlab/docmanager';
 import { Contents } from '@jupyterlab/services';
 
 import { FileBrowser } from './browser';
-import { FileBrowserModel } from './model';
-import { IFileBrowserFactory } from './factory';
+import { FilterFileBrowserModel } from './model';
+import { IFileBrowserFactory } from './tokens';
 
 /**
  * The class name added to open file dialog
@@ -101,49 +101,6 @@ export namespace FileDialog {
   }
 }
 
-/**
- * Namespace for the filtered file browser model
- */
-export namespace FilterFileBrowserModel {
-  /**
-   * Constructor options
-   */
-  export interface IOptions extends FileBrowserModel.IOptions {
-    /**
-     * Filter function on file browser item model
-     */
-    filter?: (value: Contents.IModel) => boolean;
-  }
-}
-
-/**
- * File browser model with optional filter on element.
- */
-export class FilterFileBrowserModel extends FileBrowserModel {
-  constructor(options: FilterFileBrowserModel.IOptions) {
-    super(options);
-
-    this._filter = options.filter ? options.filter : model => true;
-  }
-
-  /**
-   * Create an iterator over the filtered model's items.
-   *
-   * @returns A new iterator over the model's items.
-   */
-  items(): IIterator<Contents.IModel> {
-    return filter(super.items(), (value, index) => {
-      if (value.type === 'directory') {
-        return true;
-      } else {
-        return this._filter(value);
-      }
-    });
-  }
-
-  private _filter: (value: Contents.IModel) => boolean;
-}
-
 /**
  * Open dialog widget
  */