1 | import { __decorate } from "tslib";
|
2 | import { body } from "@pnp/queryable";
|
3 | import { _SPCollection, spInvokableFactory, _SPInstance, deleteable, } from "../spqueryable.js";
|
4 | import { defaultPath } from "../decorators.js";
|
5 | import { spPost, spPostMerge } from "../operations.js";
|
6 | import { encodePath } from "../utils/encode-path-str.js";
|
7 | let _Views = class _Views extends _SPCollection {
|
8 | |
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 | async add(Title, PersonalView = false, additionalSettings = {}) {
|
16 | const data = await spPost(this, body({
|
17 | PersonalView,
|
18 | Title,
|
19 | ...additionalSettings,
|
20 | }));
|
21 | return {
|
22 | data,
|
23 | view: this.getById(data.Id),
|
24 | };
|
25 | }
|
26 | |
27 |
|
28 |
|
29 |
|
30 |
|
31 | getById(id) {
|
32 | return View(this).concat(`('${id}')`);
|
33 | }
|
34 | |
35 |
|
36 |
|
37 |
|
38 |
|
39 | getByTitle(title) {
|
40 | return View(this, `getByTitle('${encodePath(title)}')`);
|
41 | }
|
42 | };
|
43 | _Views = __decorate([
|
44 | defaultPath("views")
|
45 | ], _Views);
|
46 | export { _Views };
|
47 | export const Views = spInvokableFactory(_Views);
|
48 | export class _View extends _SPInstance {
|
49 | constructor() {
|
50 | super(...arguments);
|
51 | this.delete = deleteable();
|
52 | }
|
53 | get fields() {
|
54 | return ViewFields(this);
|
55 | }
|
56 | |
57 |
|
58 |
|
59 |
|
60 |
|
61 | async update(props) {
|
62 | const data = await spPostMerge(this, body(props));
|
63 | return {
|
64 | data,
|
65 | view: this,
|
66 | };
|
67 | }
|
68 |
|
69 | |
70 |
|
71 |
|
72 |
|
73 | renderAsHtml() {
|
74 | return View(this, "renderashtml")();
|
75 | }
|
76 | |
77 |
|
78 |
|
79 |
|
80 |
|
81 | setViewXml(viewXml) {
|
82 | return spPost(View(this, "SetViewXml"), body({ viewXml }));
|
83 | }
|
84 | }
|
85 | export const View = spInvokableFactory(_View);
|
86 | let _ViewFields = class _ViewFields extends _SPCollection {
|
87 | |
88 |
|
89 |
|
90 | getSchemaXml() {
|
91 | return ViewFields(this, "schemaxml")();
|
92 | }
|
93 | |
94 |
|
95 |
|
96 |
|
97 |
|
98 | add(fieldTitleOrInternalName) {
|
99 | return spPost(ViewFields(this, `addviewfield('${encodePath(fieldTitleOrInternalName)}')`));
|
100 | }
|
101 | |
102 |
|
103 |
|
104 |
|
105 |
|
106 |
|
107 | move(field, index) {
|
108 | return spPost(ViewFields(this, "moveviewfieldto"), body({ field, index }));
|
109 | }
|
110 | |
111 |
|
112 |
|
113 | removeAll() {
|
114 | return spPost(ViewFields(this, "removeallviewfields"));
|
115 | }
|
116 | |
117 |
|
118 |
|
119 |
|
120 |
|
121 | remove(fieldInternalName) {
|
122 | return spPost(ViewFields(this, `removeviewfield('${encodePath(fieldInternalName)}')`));
|
123 | }
|
124 | };
|
125 | _ViewFields = __decorate([
|
126 | defaultPath("viewfields")
|
127 | ], _ViewFields);
|
128 | export { _ViewFields };
|
129 | export const ViewFields = spInvokableFactory(_ViewFields);
|
130 | export var ViewScope;
|
131 | (function (ViewScope) {
|
132 | ViewScope[ViewScope["DefaultValue"] = 0] = "DefaultValue";
|
133 | ViewScope[ViewScope["Recursive"] = 1] = "Recursive";
|
134 | ViewScope[ViewScope["RecursiveAll"] = 2] = "RecursiveAll";
|
135 | ViewScope[ViewScope["FilesOnly"] = 3] = "FilesOnly";
|
136 | })(ViewScope || (ViewScope = {}));
|
137 |
|
\ | No newline at end of file |