MCPcopy Create free account
hub / github.com/apitable/apitable / updateProperty

Method updateProperty

packages/widget-sdk/src/model/field.ts:321–352  ·  view source on GitHub ↗

* * Beta API, future changes are possible. * * Updates the property for this field, * tips: that the update property configuration must be overwritten in full. * * Throws an error if the user does not have permission to update the field, * if invalid property are provided, if

(property: any, options?: IEffectOption)

Source from the content-addressed store, hash-verified

319 * ```
320 */
321 updateProperty(property: any, options?: IEffectOption): Promise<void> {
322 const { error } = this.fieldEntity.validateUpdateOpenProperty(property, options);
323 if (error) {
324 throw new Error(JSON.stringify(error));
325 }
326 const updateProperty = this.fieldEntity.updateOpenFieldPropertyTransformProperty(property);
327 let deleteBrotherField: boolean;
328 // Two-way Link special fields, need to determine whether to delete the associated fields of the associated table
329 if (this.type === FieldType.MagicLink) {
330 const { conversion } = property as IUpdateOpenMagicLinkFieldProperty;
331 deleteBrotherField = conversion === Conversion.Delete;
332 }
333 return new Promise(async(resolve) => {
334 const result: ICollaCommandExecuteResult<any> = await cmdExecute({
335 cmd: CollaCommandName.SetFieldAttr,
336 datasheetId: this.datasheetId,
337 fieldId: this.fieldData.id,
338 deleteBrotherField,
339 data: {
340 ...this.fieldData,
341 property: updateProperty
342 }
343 }, this.wCtx.id);
344 if (result.result === ExecuteResult.Fail) {
345 throw new Error(result.reason);
346 }
347 if (result.result === ExecuteResult.None) {
348 throw new Error('update property method has been ignored');
349 }
350 resolve();
351 });
352 }
353
354 /**
355 *

Callers 2

updatePropertyAsyncMethod · 0.80
field.spec.tsFile · 0.80

Calls 4

cmdExecuteFunction · 0.90
stringifyMethod · 0.80

Tested by

no test coverage detected