當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。