-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpicker-view.js
More file actions
86 lines (74 loc) · 1.77 KB
/
Copy pathpicker-view.js
File metadata and controls
86 lines (74 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
'use strict';
import BreadcrumbView from './breadcrumb-view';
import ItemView from './item-view';
import picker from './html/picker';
/**
* The PickerView class used to build the view.
*
* It's not meant to be used directly.
*/
class PickerView {
/**
* Creates a new PickerView instance.
*/
constructor() {
this._breadcrumb = new BreadcrumbView();
this._items = [];
}
/**
* Add a new item to the grid.
* @param {object} itemData - The OneDrive item data for this item.
*/
addItem(itemData = {}) {
const item = new ItemView(itemData);
this._items.push(item);
return item;
}
/**
* Clears the items.
*/
clearItems() {
this._items = [];
}
/**
* Adds an item to the breadcrumb.
* @param {object} itemData - The item data.
*/
addItemToBreadcrumb(itemData) {
this._breadcrumb.addItem(itemData);
}
/**
* Adds a search item to the breadcrumb.
* @param {string} search - The search request.
*/
addSearchToBreadcrumb(search) {
this._breadcrumb.addSearch(search);
}
/**
* Sets the current directory to the item owning the input id.
* @param {string} itemId - The item id to set as current directory.
*/
setBreadcrumbTo(itemId) {
this._breadcrumb.setCurrent(itemId);
}
/**
* Reinitialize the breadcrumb.
*/
reinitBreadcrumb() {
this._breadcrumb.reinit();
}
/**
* Builds the picker.
*/
build() {
const _picker = jQuery(picker);
const _insertBreadcrumb = _picker.find('[onedrive-insert-breadcrumb]');
_insertBreadcrumb.append(this._breadcrumb.build());
const _insertItems = _picker.find('[onedrive-insert-items]');
for (const item of this._items) {
_insertItems.append(item.build());
}
return _picker;
}
}
export default PickerView;