Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
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();
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';
}
// 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, {
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);
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]});
}
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] });
componentWillMount: function() {
this.formio = new Formiojs(Formiojs.getBaseUrl() + '/project/' + this.props.component.project + '/form/' + this.props.component.resource);
this.refreshItems();
},
getValueField: function() {