Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

alaska-field-relationship

Package Overview
Dependencies
Maintainers
1
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

alaska-field-relationship - npm Package Compare versions

Comparing version 0.12.2 to 0.12.3

6

index.js

@@ -114,2 +114,3 @@ 'use strict';

this.dataType = type;
// $Flow
schema.path(this.path, this.multi ? [options] : options);

@@ -171,3 +172,3 @@

RelationshipField.plain = TypeObjectId;
RelationshipField.viewOptions = ['filters', 'service', 'model', 'multi', 'checkbox', 'switch', (options, field) => {
RelationshipField.viewOptions = ['filters', 'multi', 'checkbox', 'switch', (options, field) => {
let Model = field.ref;

@@ -177,5 +178,2 @@ if (Model) {

options.title = Model.titleField;
if (!options.service && Model.service) {
options.service = Model.service.id;
}
}

@@ -182,0 +180,0 @@ }];

{
"name": "alaska-field-relationship",
"version": "0.12.2",
"version": "0.12.3",
"description": "Alaska relationship field",

@@ -5,0 +5,0 @@ "keywords": [

@@ -49,6 +49,9 @@ // @flow

let { field, details, settings } = this.props;
if (!field.ref) return null;
let Model = settings.models[field.ref];
// $Flow 下方做了判断,保证ref一定存在
const ref: string = field.ref;
if (!ref) return null;
let Model = settings.models[ref];
let { key } = Model;
let title = value;
let [refServiceId, refModelName] = ref.split('.');
if (value && details && details[key] && details[key][value]) {

@@ -59,4 +62,4 @@ title = details[key][value][Model.titleField] || value;

this.props.loadDetails({
service: field.service,
model: field.model,
service: refServiceId,
model: refModelName,
key,

@@ -69,3 +72,3 @@ id: value

key={value}
to={'/edit/' + field.service + '/' + field.model + '/' + encodeURIComponent(value)}
to={'/edit/' + refServiceId + '/' + refModelName + '/' + encodeURIComponent(value)}
>{title}</Link>);

@@ -72,0 +75,0 @@ }

@@ -33,10 +33,12 @@ // @flow

super(props);
let v = props.value || {};
if (typeof v === 'string') {
v = { value: v };
let value: {
value?: string | number
// $Flow
} = props.value || {};
if (typeof value === 'string' || typeof value === 'number') {
value = { value };
}
let value: Alaska$filter = v;
this.state = {
value: value.value === undefined ? '' : value.value,
inverse: value.inverse || false,
inverse: value.inverse === true || value.inverse === 'true',
error: value.value === undefined,

@@ -50,5 +52,6 @@ options: []

if (value !== this.props.value) {
if (typeof value === 'string') {
if (typeof value !== 'object') {
value = { value };
}
// $Flow
this.setState(value);

@@ -64,5 +67,9 @@ }

let { field, value } = this.props;
// $Flow 下方做了判断,保证ref一定存在
const ref: string = field.ref;
if (!ref) return;
let [refServiceId, refModelName] = ref.split('.');
api('/api/relation')
.param('service', field.service)
.param('model', field.model)
.param('service', refServiceId)
.param('model', refModelName)
.param('value', value)

@@ -76,3 +83,4 @@ .search(keyword)

handleChange = (value: string) => {
handleChange = (value: Alaska$SelectField$value) => {
// $Flow 我们知道这里value不会是数组
this.setState({ value }, () => this.handleBlur());

@@ -79,0 +87,0 @@ };

@@ -13,2 +13,3 @@ // @flow

function getOptionValue(opt) {
if (Array.isArray(opt)) return '';
if (opt && typeof opt === 'object') return opt.value;

@@ -61,3 +62,3 @@ return opt;

handleChange = (value: string | number) => {
handleChange = (value: Alaska$SelectField$value) => {
if (this.props.onChange) {

@@ -80,2 +81,5 @@ let val = null;

const { field, record, value } = this.props;
// $Flow 下方做了判断,保证ref一定存在
const ref: string = field.ref;
if (!ref) return;
let filters = _.reduce(field.filters || {}, (res: {}, v: any, key: string) => {

@@ -98,5 +102,7 @@ res[key] = v;

const [serviceId, modelName] = ref.split('.');
api('/api/relation')
.param('service', field.service)
.param('model', field.model)
.param('service', serviceId)
.param('model', modelName)
.param('value', value)

@@ -130,2 +136,9 @@ .search(keyword)

let helpElement = help ? <p className="help-block">{help}</p> : null;
let refServiceId = '';
let refModelName = '';
// $Flow 下方做了判断,保证ref一定存在
const ref: string = field.ref;
if (ref) {
[refServiceId, refModelName] = ref.split('.');
}

@@ -149,4 +162,4 @@ let inputElement;

opts.map((opt: Alaska$SelectField$option) => (<a
key={opt.value}
href={`#/edit/${field.service}/${field.model}/${String(opt.value)}`}
key={String(opt.value)}
href={`#/edit/${refServiceId}/${refModelName}/${String(opt.value)}`}
style={{ paddingRight: 10 }}

@@ -153,0 +166,0 @@ >{opt.label}

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc