当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript ng2-json-editor.JsonStoreService类代码示例

本文整理汇总了TypeScript中ng2-json-editor.JsonStoreService的典型用法代码示例。如果您正苦于以下问题:TypeScript JsonStoreService类的具体用法?TypeScript JsonStoreService怎么用?TypeScript JsonStoreService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了JsonStoreService类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: splitPrimitiveReferenceField

export function splitPrimitiveReferenceField(path: Array<any>, value: string, jsonStore: JsonStoreService, keyStore: KeysStoreService) {
  let splitResult = splitReferenceField(value);
  // parent path, ['references', N, 'reference']
  let referencePath = path.slice(0, -2);
  splitResult.splits.forEach(split => {
    // handle array insert
    let relativePath = split.path;
    let insertLast = relativePath.findIndex(el => el === '-');
    if (insertLast > -1) {
      let valueToInsert;
      let sliceIndex = insertLast + 1;
      let insertPath = relativePath.slice(0, sliceIndex);
      if (sliceIndex < relativePath.length) {
        let afterInsertPath = relativePath.slice(sliceIndex);
        let stub = {};
        stub[afterInsertPath[afterInsertPath.length - 1]] = split.value;
        for (let i = afterInsertPath.length - 2; i >= 0; i--) {
          let temp = { [afterInsertPath[i]]: stub };
          stub = temp;
        }
        valueToInsert = stub;
      } else {
        valueToInsert = split.value;
      }
      let fullInsertPath = referencePath.concat(insertPath);
      jsonStore.addIn(fullInsertPath, valueToInsert);
    } else {
      let toPath = referencePath.concat(split.path);
      jsonStore.setIn(toPath, split.value);
    }

  });
  // if all of field is splitted, remove it
  if (!splitResult.unsplitted) {
    let parentPath = path.slice(0, -1);
    // remove even it's parent, if the field is the only element in an array
    if (Number.isInteger(path[path.length - 1]) && jsonStore.getIn(parentPath).size <= 1) {
      jsonStore.removeIn(parentPath);
    } else {
      jsonStore.removeIn(path);
    }
  } else {
    jsonStore.setIn(path, splitResult.unsplitted);
  }
  keyStore.buildKeysMapRecursivelyForPath(jsonStore.getIn(referencePath), referencePath);
}
开发者ID:inspirehep,项目名称:record-editor,代码行数:46,代码来源:commons.ts

示例2:

  splitResult.splits.forEach(split => {
    // handle array insert
    let relativePath = split.path;
    let insertLast = relativePath.findIndex(el => el === '-');
    if (insertLast > -1) {
      let valueToInsert;
      let sliceIndex = insertLast + 1;
      let insertPath = relativePath.slice(0, sliceIndex);
      if (sliceIndex < relativePath.length) {
        let afterInsertPath = relativePath.slice(sliceIndex);
        let stub = {};
        stub[afterInsertPath[afterInsertPath.length - 1]] = split.value;
        for (let i = afterInsertPath.length - 2; i >= 0; i--) {
          let temp = { [afterInsertPath[i]]: stub };
          stub = temp;
        }
        valueToInsert = stub;
      } else {
        valueToInsert = split.value;
      }
      let fullInsertPath = referencePath.concat(insertPath);
      jsonStore.addIn(fullInsertPath, valueToInsert);
    } else {
      let toPath = referencePath.concat(split.path);
      jsonStore.setIn(toPath, split.value);
    }

  });
开发者ID:inspirehep,项目名称:record-editor,代码行数:28,代码来源:commons.ts

示例3: onClick

 onClick() {
   let rollbackPath = this.jsonStoreService.rollbackLastChange();
   if (rollbackPath) {
     setTimeout(( ) => {
       this.domUtilService.focusAndSelectFirstEditableChildById(rollbackPath, true);
     });
   }
 }
开发者ID:harunurhan,项目名称:record-editor,代码行数:8,代码来源:undo-button.component.ts

示例4: onLinkButtonClick

  onLinkButtonClick() {
    let infoToast = this.toastrService.info('Linking references...', 'Loading', HOVER_TO_DISMISS_INDEFINITE_TOAST);

    const references = this.jsonStoreService.getIn(['references']);
    this.apiService.getLinkedReferences(references)
      .then(linkedReferences => {
        this.jsonStoreService.setIn(['references'], linkedReferences);

        this.toastrService.clear(infoToast.toastId);
        this.toastrService.success(`References are linked.`, 'Success');
      }).catch(error => {
        this.toastrService.clear(infoToast.toastId);
        this.toastrService.error('Could not link references', 'Error');
      });
  }
开发者ID:inspirehep,项目名称:record-editor,代码行数:15,代码来源:link-references-button.component.ts

示例5:

      .then(linkedReferences => {
        this.jsonStoreService.setIn(['references'], linkedReferences);

        this.toastrService.clear(infoToast.toastId);
        this.toastrService.success(`References are linked.`, 'Success');
      }).catch(error => {
开发者ID:inspirehep,项目名称:record-editor,代码行数:6,代码来源:link-references-button.component.ts

示例6:

        .subscribe(uploadedPath => {
          this.jsonStoreService.addIn(['documents', '-'], { url: uploadedPath, key: file.name });

          this.toastrService.clear(infoToast.toastId);
          this.toastrService.success(`File uploaded`, 'Success');
        }, error => {
开发者ID:inspirehep,项目名称:record-editor,代码行数:6,代码来源:file-upload-button.component.ts


注:本文中的ng2-json-editor.JsonStoreService类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。