How to use the babel/utils/helper/Helper.attachmentUtils function in babel

To help you get started, we’ve selected a few babel examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Esri / storymap-crowdsource / src / app / components / selectedShares / SelectedDisplay.babel.js View on Github external
switch (media.type) {
      case 'video':
        // add video
        break;
      default:
        let photoUrl;

        if (fieldProps.isAttachment) {
          const attachmentUrl = Helper.attachmentUtils.getAttachmentUrlsByStringMatch({
            layer: this.props.layer,
            feature: this.props.feature,
            match: media.field,
            position: 0
          })[0] || '';

          photoUrl = Helper.attachmentUtils.checkForCredential({
            url: attachmentUrl,
            layer: this.props.layer
          });
        } else {
          photoUrl = Helper.attachmentUtils.checkForCredential({
            url: this.props.thumbnailUrlPrepend + attributes[media.field] + this.props.thumbnailUrlAppend,
            layer: this.props.layer
          });
        }

        return (
          <div className="media-section">
            <LazyImage
              key={photoUrl}
              className="media-photo"
              autoSizeDiv={true}
github Esri / storymap-crowdsource / src / app / components / intro / IntroSplash.babel.js View on Github external
<InlineEditorWrapper
      editingAllowed={this.props.editingAllowed}
      component="div"
      addNotifications={this.props.addNotifications}
      removeNotifications={this.props.removeNotifications}>
        <button className="explore text-btn background-fill" inlineEditDisableActions="true" onClick={this.props.exploreAction}>
          <p className="text inline-editable" inlineEditConfig={this.getEditConfig('exploreButton')}>{this.props.exploreText}</p>
          <div className="icon-arrow-down" dangerouslySetInnerHTML={{__html: getIcon('arrow-down-open')}}></div>
        </button>
      </InlineEditorWrapper> : null;

    let background;

    switch (this.props.background.type) {
      case 'photo':
        const backgroundUrl = Helper.attachmentUtils.checkForCredential({
          url: this.props.background.source,
          portal: this.props.portal
        });

        background = <LazyImage className="background-image" src={backgroundUrl}></LazyImage>;
        break;
    }

    return (
      <div className={introClass}>
        {builderText && !this.props.editingAllowed ? (
          // TODO check builder mode instead of if builder text
          <button
            onClick={this.props.editAction}
            className="background-edit-button btn btn-primary btn-lg"
            dangerouslySetInnerHTML={{__html: getIcon('edit')}}></button>
github Esri / storymap-crowdsource / src / app / controllers / builder / appItemAttachments / AppItemAttachments.babel.js View on Github external
uploadAttachment(data) {
    const portal = lang.getObject('appState.app.portal',false,this);
    let filename;
    let attachment;

    switch (data.type) {
      case 'photo':
        filename = data.id + data.attachment.ext;
        attachment = Helper.attachmentUtils.dataURItoBlob(data.attachment.source);
        break;
    }

    portal.uploadAppItemAttachments({
      attachment,
      filename
    }).then((url) => {
      if (data.removeAttachments) {
        portal.removeAttachments({
          keep: filename,
          filter: data.removeFilter
        });
      }
      if (typeof data.callback === 'function') {
        data.callback(url);
      }
github Esri / storymap-crowdsource / src / app / controllers / contribute / ContrbuteController.babel.js View on Github external
Object.keys(graphic.attributes).forEach((key) => {
        const value = graphic.attributes[key];

        if (typeof value === 'object' && value.attachment && value.type) {
          switch (value.type) {
            case 'photo':
              attachments.push({
                field: key,
                filename: key + value.ext,
                attachment: Helper.attachmentUtils.dataURItoBlob(value.source),
                url: false
              });
              delete graphic.attributes[key];
              break;
            default:

          }
        } else if (typeof value === 'object') {
          graphic.attributes[key] = JSON.stringify(value);
        } else if (typeof value === 'string') {
          graphic.attributes[key] = value.sanitizeHtml();
        }
      });
github Esri / storymap-crowdsource / src / app / stores / CrowdsourceAppStore.babel.js View on Github external
$.each(g.attributes, (key,value) => {
      if (typeof value === 'object' && value.attachment && value.type) {
        switch (value.type) {
          case 'photo':
            g.attributes[key] = 'ATTACHMENT_' + key;
            attachments.push({
              field: key,
              filename: key + value.ext,
              attachment: Helper.attachmentUtils.dataURItoBlob(value.source)
            });
            break;
        }
      } else if (typeof value === 'object') {
        g.attributes[key] = JSON.stringify(value);
      }
    });
  }
github Esri / storymap-crowdsource / src / app / components / header / Header.babel.js View on Github external
render() {

    const headerClass = Helper.classnames([this.props.className, 'header', 'navbar', 'main-app-header']);
    const participateIconHtml = {
      __html: getIcon('participate')
    };
    const participateBtn = this.props.showParticipateActionButton ? (
      <button ref={(ref) => this.participateBtn = ref} className={Helper.classnames(['participate', 'btn', 'btn-primary', 'nav-btn'],{
          disabled: this.props.participationButtonDisabled
        })} onClick={this.participateAction}>
        <span className="icon" dangerouslySetInnerHTML={participateIconHtml}></span>
        <span className="text">{this.props.participateShort}</span>
      </button>
    ) : null;

    const logoUrl = Helper.attachmentUtils.checkForCredential({
      url: this.props.logo.source,
      portal: this.props.portal
    });

    const includeSharing = Object.keys(this.props.sharing.services).filter((key) => {
      return this.props.sharing.services[key] === true;
    }).length > 0;

    return (
      <header className={headerClass}>
        <div className="cell-wrapper">
          {this.props.logo.type === 'none' || logoUrl.length === 0 ? null : (
            <a href={this.props.logo.link} className="logo-link cell" target="_blank">
              <img src={logoUrl} className="logo" alt={this.props.logo.link} />
            </a>
          )}
github Esri / storymap-crowdsource / src / app / components / selectedShares / SelectedDisplay.babel.js View on Github external
let photoUrl;

        if (fieldProps.isAttachment) {
          const attachmentUrl = Helper.attachmentUtils.getAttachmentUrlsByStringMatch({
            layer: this.props.layer,
            feature: this.props.feature,
            match: media.field,
            position: 0
          })[0] || '';

          photoUrl = Helper.attachmentUtils.checkForCredential({
            url: attachmentUrl,
            layer: this.props.layer
          });
        } else {
          photoUrl = Helper.attachmentUtils.checkForCredential({
            url: this.props.thumbnailUrlPrepend + attributes[media.field] + this.props.thumbnailUrlAppend,
            layer: this.props.layer
          });
        }

        return (
          <div className="media-section">
            <LazyImage
              key={photoUrl}
              className="media-photo"
              autoSizeDiv={true}
              src={photoUrl}
              onLoad={this.onMediaLoad.bind(this,true)}
              onError={this.onMediaLoad.bind(this,false)}>
            </LazyImage>
          </div>
github Esri / storymap-crowdsource / src / app / components / gallery / ThumbnailGallery.babel.js View on Github external
galleryItemRender(item,index) {
    const attr = this.props.attributePath ? Helper.objectUtils.getDescendentProperty(item,this.props.attributePath) : item;
    const endTile = index % this.state.tileSettings.tilesPerRow === 0;
    let photoUrl;

    if (this.props.thumbnailIsAttachment) {
      const attachmentUrl = Helper.attachmentUtils.getAttachmentUrlsByStringMatch({
        layer: this.props.layer,
        feature: item,
        match: this.props.thumbnailField,
        position: 0
      })[0] || '';

      photoUrl = Helper.attachmentUtils.checkForCredential({
        url: attachmentUrl,
        layer: this.props.layer
      });
    } else {
      photoUrl = Helper.attachmentUtils.checkForCredential({
        url: this.props.thumbnailUrlPrepend + attr[this.props.thumbnailField] + this.props.thumbnailUrlAppend,
        layer: this.props.layer
      });
    }

    const itemStyle = {
      height: this.state.tileSettings.tileSize,
      width: endTile ? this.state.tileSettings.tileSize - 0.5 : this.state.tileSettings.tileSize
    };

    const itemClasses = Helper.classnames(['gallery-item', {
github Esri / storymap-crowdsource / src / app / components / gallery / ThumbnailGallery.babel.js View on Github external
galleryItemRender(item,index) {
    const attr = this.props.attributePath ? Helper.objectUtils.getDescendentProperty(item,this.props.attributePath) : item;
    const endTile = index % this.state.tileSettings.tilesPerRow === 0;
    let photoUrl;

    if (this.props.thumbnailIsAttachment) {
      const attachmentUrl = Helper.attachmentUtils.getAttachmentUrlsByStringMatch({
        layer: this.props.layer,
        feature: item,
        match: this.props.thumbnailField,
        position: 0
      })[0] || '';

      photoUrl = Helper.attachmentUtils.checkForCredential({
        url: attachmentUrl,
        layer: this.props.layer
      });
    } else {
      photoUrl = Helper.attachmentUtils.checkForCredential({
        url: this.props.thumbnailUrlPrepend + attr[this.props.thumbnailField] + this.props.thumbnailUrlAppend,
        layer: this.props.layer
      });
    }