Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// borrowed from the Backbone.Associations tutorials
// separated out into modules to avoid namespace clashes
import * as Backbone from 'backbone';
// one-to-one tests
class EmployeeWithManager extends Backbone.AssociatedModel {
constructor(options?) {
super(options);
this.relations = [
{
type: Backbone.One, //nature of the relationship
key: 'manager', // attribute of Employee
relatedModel: 'Employee' //AssociatedModel for attribute key
}
];
}
defaults() {
return {
age: 0,
fname: "",
lname: "",
return {
add1: "",
add2: null,
zip: "",
state: ""
};
}
}
class Locations extends Backbone.Collection {
comparator = (c: Backbone.Model) => {
return c.get("Number");
}
}
class Project extends Backbone.AssociatedModel {
constructor(options?) {
super(options);
this.relations = [
{
type: Backbone.Many, //nature of the relation
key: 'locations', //attribute of Project
collectionType: Locations, //Collection to be used.
relatedModel: Location //Optional
}
];
}
defaults() {
return {
name: "",
number: 0,
},
getHoverPreview() {
return this.get('hoverPreview')
},
getQuerySettings() {
return this.get('querySettings')
},
parse(data, options) {
if (options && options.drop) {
return {}
}
return data
},
})
User.Model = Backbone.AssociatedModel.extend({
defaults() {
return {
id: 'user',
preferences: new User.Preferences(),
isGuest: true,
username: 'guest',
userid: 'guest',
roles: ['guest'],
}
},
relations: [
{
type: Backbone.One,
key: 'preferences',
relatedModel: User.Preferences,
},
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details. A copy of the GNU Lesser General Public License
* is distributed along with this program and can be found at
* .
*
**/
const _ = require('underscore')
const Backbone = require('backbone')
const Metacard = require('../../js/model/Metacard.js')
const Query = require('../../js/model/Query.js')
const QueryResponse = require('../../js/model/QueryResponse.js')
const QueryResult = require('../../js/model/QueryResult.js')
module.exports = Backbone.AssociatedModel.extend({
relations: [
{
type: Backbone.One,
key: 'currentQuery',
relatedModel: Query.Model,
},
{
type: Backbone.One,
key: 'currentMetacard',
relatedModel: QueryResponse,
},
{
type: Backbone.Many,
key: 'selectedResults',
relatedModel: Metacard,
},
let promiseIsResolved = false
const sharedSearchFormPromise = () =>
$.ajax({
type: 'GET',
context: this,
url: './internal/forms/query',
contentType: 'application/json',
success: function(data) {
sharedTemplates = data
promiseIsResolved = true
},
})
let bootstrapPromise = sharedSearchFormPromise()
module.exports = Backbone.AssociatedModel.extend({
model: SearchForm,
defaults: {
doneLoading: false,
sharedSearchForms: [],
},
initialize: function() {
this.addMySharedForms()
},
relations: [
{
type: Backbone.Many,
key: 'sharedSearchForms',
collectionType: Backbone.Collection.extend({
model: SearchForm,
initialize: function() {},
}),
* .
*
**/
const _ = require('underscore')
const Backbone = require('backbone')
const Metacard = require('../../js/model/Metacard.js')
const Alert = require('../../js/model/Alert.js')
const Query = require('../../js/model/Query.js')
const QueryResponse = require('../../js/model/QueryResponse.js')
const QueryResult = require('../../js/model/QueryResult.js')
const router = require('../router/router.js')
const user = require('../singletons/user-instance.js')
const cql = require('../../js/cql.js')
module.exports = new (Backbone.AssociatedModel.extend({
relations: [
{
type: Backbone.One,
key: 'currentQuery',
relatedModel: Query.Model,
},
{
type: Backbone.One,
key: 'currentResult',
relatedModel: QueryResponse,
},
{
type: Backbone.One,
key: 'currentAlert',
relatedModel: Alert,
},
* General Public License as published by the Free Software Foundation, either version 3 of the
* License, or any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details. A copy of the GNU Lesser General Public License
* is distributed along with this program and can be found at
* .
*
**/
const Backbone = require('backbone')
const PropertyModel = require('../property/property.js')
require('backbone-associations')
module.exports = Backbone.AssociatedModel.extend({
defaults: {
value: undefined,
isValid: true,
property: undefined,
},
relations: [
{
type: Backbone.One,
key: 'property',
relatedModel: PropertyModel,
},
],
setValue(value) {
this.set('value', value)
},
getValue() {
}
},
promise() {
const d = $.Deferred()
promise
.then(value => {
d.resolve(value)
})
.catch(err => {
d.reject(err)
})
return d
},
}
} else {
return Backbone.AssociatedModel.prototype.sync.call(
this,
method,
model,
options
)
}
},
handleError(resultModel, response, sent) {
filters: bookmarks.map(function (id) {
return {
type: '=',
value: id,
property: '"id"'
};
})
}, {
type: 'ILIKE',
value: '*',
property: '"metacard-tags"'
}]
});
}
module.exports = Backbone.AssociatedModel.extend({
defaults: function () {
return {
id: Common.generateUUID(),
title: 'Untitled List',
'list.cql': '',
'list.icon': 'folder',
'list.bookmarks': [],
query: undefined
};
},
relations: [{
type: Backbone.One,
key: 'query',
relatedModel: Query.Model,
isTransient: true
}],
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details. A copy of the GNU Lesser General Public License
* is distributed along with this program and can be found at
* .
*
**/
const Backbone = require('backbone')
const _ = require('underscore')
const metacardDefinitions = require('../../component/singletons/metacard-definitions.js')
const TurfMeta = require('@turf/meta')
const wkx = require('wkx')
const properties = require('../properties.js')
require('backbone-associations')
module.exports = Backbone.AssociatedModel.extend({
defaults() {
return {
'metacard-tags': ['resource'],
}
},
hasGeometry(attribute) {
return (
_.filter(
this.toJSON(),
(value, key) =>
(attribute === undefined || attribute === key) &&
metacardDefinitions.metacardTypes[key] &&
metacardDefinitions.metacardTypes[key].type === 'GEOMETRY'
).length > 0
)
},