@@ -24,8 +24,8 @@ export class Collection<T extends Content> {
24
24
* @param { IODataApi<any, any> } service The service to use as API Endpoint
25
25
*/
26
26
constructor ( private items : T [ ] ,
27
- private repository : BaseRepository ,
28
- private readonly contentType : { new ( ...args : any [ ] ) : T } = Content . constructor as { new ( ...args : any [ ] ) : any } ) {
27
+ private repository : BaseRepository ,
28
+ private readonly contentType : { new ( ...args : any [ ] ) : T } = Content as { new ( ...args : any [ ] ) : any } ) {
29
29
this . odata = repository . GetODataApi ( ) ;
30
30
}
31
31
@@ -115,7 +115,6 @@ export class Collection<T extends Content> {
115
115
* });
116
116
* ```
117
117
*/
118
- public Remove ( index : number , permanently ?: boolean ) : Observable < any > ;
119
118
/**
120
119
* Method to remove an item from a local collection and from the Content Repository through OData REST API at the same time.
121
120
*
@@ -135,11 +134,10 @@ export class Collection<T extends Content> {
135
134
* });
136
135
* ```
137
136
*/
138
- public Remove ( items : number [ ] , permanently ?: boolean ) : Observable < any > ;
139
- public Remove ( arg : any , permanently : boolean = false ) : Observable < any > {
137
+ public Remove ( arg : number | number [ ] , permanently : boolean = false ) : Observable < any > {
140
138
if ( typeof arg === 'number' ) {
141
139
let content = this . items [ arg ] ;
142
- if ( content && content . Id ) {
140
+ if ( content && content . Id ) {
143
141
this . items =
144
142
this . items . slice ( 0 , arg )
145
143
. concat ( this . items . slice ( arg + 1 ) ) ;
@@ -181,18 +179,16 @@ export class Collection<T extends Content> {
181
179
*/
182
180
public Read ( path : string , options ?: IODataParams ) : Observable < any > {
183
181
this . Path = path ;
184
- let o = { } ;
182
+ let o : any = { } ;
185
183
if ( typeof options !== 'undefined' ) {
186
184
o [ 'params' ] = options ;
187
185
}
188
186
o [ 'path' ] = path ;
189
187
let optionList = new ODataRequestOptions ( o as ODataRequestOptions ) ;
190
- const children = this . odata . Fetch < T > ( optionList ) ;
191
- children
192
- . subscribe (
193
- ( items ) => {
194
- this . items = items . d . results . map ( c => this . repository . HandleLoadedContent ( c , this . contentType ) ) ;
195
- }
188
+ const children = this . odata . Fetch < T > ( optionList )
189
+ . map ( items => {
190
+ return items . d . results . map ( c => this . repository . HandleLoadedContent ( c , this . contentType ) ) ;
191
+ }
196
192
) ;
197
193
return children ;
198
194
}
@@ -213,7 +209,6 @@ export class Collection<T extends Content> {
213
209
* });
214
210
* ```
215
211
*/
216
- public Move ( index : number , targetPath : string ) : Observable < any > ;
217
212
/**
218
213
* Method to move multiple content to another container.
219
214
* @param items {number[]} number array of content indexes.
@@ -231,8 +226,7 @@ export class Collection<T extends Content> {
231
226
* });
232
227
* ```
233
228
*/
234
- public Move ( items : number [ ] , targetPath : string ) : Observable < any > ;
235
- public Move ( arg : any , targetPath : string ) : Observable < any > {
229
+ public Move ( arg : number | number [ ] , targetPath : string ) : Observable < any > {
236
230
if ( typeof arg === 'number' ) {
237
231
this . items =
238
232
this . items . slice ( 0 , arg )
@@ -265,26 +259,25 @@ export class Collection<T extends Content> {
265
259
* });
266
260
* ```
267
261
*/
268
- public Copy ( index : number , targetPath : string ) : Observable < any > ;
262
+
269
263
/**
270
- * Method to copy multiple content to another container.
271
- * @param items {number[]} number array of content indexes.
272
- * @params targetPath {string} Path of the target container.
273
- * @returns {Observable } Returns an RxJS observable that you can subscribe of in your code.
274
- * ```
275
- * let copy = myCollection.Copy([3, 5], '/Root/MyContent/MyFolder');
276
- * copy
277
- * .subscribe({
278
- * next: response => {
279
- * //do something after copy
280
- * },
281
- * error: error => console.error('something wrong occurred: ' + error),
282
- * complete: () => console.log('done'),
283
- * });
284
- * ```
285
- */
286
- public Copy ( items : number [ ] , targetPath : string ) : Observable < any > ;
287
- public Copy ( arg : any , targetPath : string ) : Observable < any > {
264
+ * Method to copy multiple content to another container.
265
+ * @param items {number[]} number array of content indexes.
266
+ * @params targetPath {string} Path of the target container.
267
+ * @returns {Observable } Returns an RxJS observable that you can subscribe of in your code.
268
+ * ```
269
+ * let copy = myCollection.Copy([3, 5], '/Root/MyContent/MyFolder');
270
+ * copy
271
+ * .subscribe({
272
+ * next: response => {
273
+ * //do something after copy
274
+ * },
275
+ * error: error => console.error('something wrong occurred: ' + error),
276
+ * complete: () => console.log('done'),
277
+ * });
278
+ * ```
279
+ */
280
+ public Copy ( arg : number | number [ ] , targetPath : string ) : Observable < any > {
288
281
if ( typeof arg === 'number' ) {
289
282
let action = new CustomAction ( { name : 'Copy' , id : arg , isAction : true , requiredParams : [ 'targetPath' ] } ) ;
290
283
return this . odata . CreateCustomAction ( action , { data : [ { 'targetPath' : targetPath } ] } ) ;
@@ -311,7 +304,7 @@ export class Collection<T extends Content> {
311
304
* ```
312
305
*/
313
306
public AllowedChildTypes ( options ?: Object ) : Observable < any > {
314
- let o = { } ;
307
+ let o : any = { } ;
315
308
if ( options ) {
316
309
o [ 'params' ] = options ;
317
310
}
@@ -335,7 +328,7 @@ export class Collection<T extends Content> {
335
328
* @returns {Observable } Returns an RxJS observable that you can subscribe of in your code.
336
329
*/
337
330
public Upload ( contentType : string , fileName : string , overwrite : boolean = true , useChunk : boolean = false , propertyName ?: string , fileText ?: string ) : Observable < any > {
338
- const data = {
331
+ const data : any = {
339
332
ContentType : contentType ,
340
333
FileName : fileName ,
341
334
Overwrite : overwrite ,
0 commit comments