How to use the formiojs.getBaseUrl function in formiojs

To help you get started, we’ve selected a few formiojs 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 formio / react-formio / src / components / FormComponents / select.jsx View on Github external
}
          catch (error) {
            console.warn('Error calculating select components in ' + this.props.component.key, error);
            this.setState({
              selectItems: []
            });
          }
        };
        this.refreshItems();
        break;
      case 'resource':
      case 'url':
        if (this.props.component.dataSrc === 'url') {
          this.url = this.props.component.data.url;
          if (this.url.substr(0, 1) === '/') {
            this.url = formiojs.getBaseUrl() + this.props.component.data.url;
          }

          // Disable auth for outgoing requests.
          if (!this.props.component.authenticate && this.url.indexOf(formiojs.getBaseUrl()) === -1) {
            this.options = {
              disableJWT: true,
              headers: {
                Authorization: undefined,
                Pragma: undefined,
                'Cache-Control': undefined
              }
            };
          }
        }
        else {
          this.url = formiojs.getBaseUrl();
github formio / react-formio / src / components / FormComponents / select.jsx View on Github external
selectItems: []
            });
          }
        };
        this.refreshItems();
        break;
      case 'resource':
      case 'url':
        if (this.props.component.dataSrc === 'url') {
          this.url = this.props.component.data.url;
          if (this.url.substr(0, 1) === '/') {
            this.url = formiojs.getBaseUrl() + this.props.component.data.url;
          }

          // Disable auth for outgoing requests.
          if (!this.props.component.authenticate && this.url.indexOf(formiojs.getBaseUrl()) === -1) {
            this.options = {
              disableJWT: true,
              headers: {
                Authorization: undefined,
                Pragma: undefined,
                'Cache-Control': undefined
              }
            };
          }
        }
        else {
          this.url = formiojs.getBaseUrl();
          if (this.props.component.data.project) {
            this.url += '/project/' + this.props.component.data.project;
          }
          this.url += '/form/'  + this.props.component.data.resource + '/submission';
github formio / react-formio / src / components / FormComponents / select.jsx View on Github external
}

          // Disable auth for outgoing requests.
          if (!this.props.component.authenticate && this.url.indexOf(formiojs.getBaseUrl()) === -1) {
            this.options = {
              disableJWT: true,
              headers: {
                Authorization: undefined,
                Pragma: undefined,
                'Cache-Control': undefined
              }
            };
          }
        }
        else {
          this.url = formiojs.getBaseUrl();
          if (this.props.component.data.project) {
            this.url += '/project/' + this.props.component.data.project;
          }
          this.url += '/form/'  + this.props.component.data.resource + '/submission';
        }

        this.options.params = {
          limit: this.props.component.limit || 100,
          skip: 0
        };

        this.refreshItems = (input, newUrl, append) => {
          let { data, row } = this.props;
          newUrl = newUrl || this.url;
          // Allow templating the url.
          newUrl = interpolate(newUrl, {
github formio / react-formio / src / components / FormComponents / select.jsx View on Github external
this.refreshItems = (input, newUrl, append) => {
          let { data, row } = this.props;
          newUrl = newUrl || this.url;
          // Allow templating the url.
          newUrl = interpolate(newUrl, {
            data,
            row,
            formioBase: formiojs.getBaseUrl()
          });
          if (!newUrl) {
            return;
          }

          // If this is a search, then add that to the filter.
          if (this.props.component.searchField && input) {
            // If they typed in a search, reset skip.
            if (this.lastInput !== input) {
              this.lastInput = input;
              this.options.params.skip = 0;
            }
            newUrl += ((newUrl.indexOf('?') === -1) ? '?' : '&') +
              encodeURIComponent(this.props.component.searchField) +
              '=' +
              encodeURIComponent(input);
github formio / angular-formio / src / components / resource / resource.ts View on Github external
public searchData(text: any): void {
        let selectItems: IdTextPair[] = [];
        let templates = this.component.settings.template.split(' ')[1].split('.');
        let data: string = templates[1];
        let key: string = templates[2];
        let baseUrl: string = Formio.getBaseUrl() +'/project/'+ this.component.settings.project +'/form/'+ this.component.settings.resource;
        let params: any = {};
        if (this.component.settings.selectFields) {
            params.select = this.component.settings.selectFields;
        }
        if (this.component.settings.searchFields && text) {
            this.component.settings.searchFields.forEach((item: any) => {
                params[item] = text;
            });
        }
        (new Formio(baseUrl)).loadSubmissions({params: params}).then((submission: any) => {
            for(let i=0; i < submission.length; i++) {
                if (templates.length == 2) {
                    selectItems.push({id: submission[i], text: JSON.stringify(submission[i][data])});
                } else {
                    selectItems.push({id: submission[i], text: submission[i][data][key]});
                }
github formio / angular-formio / dist / components / resource / resource.js View on Github external
ResourceElement.prototype.searchData = function (text) {
        var _this = this;
        var selectItems = [];
        var templates = this.component.settings.template.split(' ')[1].split('.');
        var data = templates[1];
        var key = templates[2];
        var baseUrl = Formio.getBaseUrl() + '/project/' + this.component.settings.project + '/form/' + this.component.settings.resource;
        var params = {};
        if (this.component.settings.selectFields) {
            params.select = this.component.settings.selectFields;
        }
        if (this.component.settings.searchFields && text) {
            this.component.settings.searchFields.forEach(function (item) {
                params[item] = text;
            });
        }
        (new Formio(baseUrl)).loadSubmissions({ params: params }).then(function (submission) {
            for (var i = 0; i < submission.length; i++) {
                if (templates.length == 2) {
                    selectItems.push({ id: submission[i], text: JSON.stringify(submission[i][data]) });
                }
                else {
                    selectItems.push({ id: submission[i], text: submission[i][data][key] });
github formio / react-formio / src / components / FormComponents / resource.jsx View on Github external
componentWillMount: function() {
    this.formio = new Formiojs(Formiojs.getBaseUrl() + '/project/' + this.props.component.project + '/form/' + this.props.component.resource);
    this.refreshItems();
  },
  getValueField: function() {