Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
webmapsjs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Glenn Vorhes
webmapsjs
Commits
87c7ff14
Commit
87c7ff14
authored
5 years ago
by
Glenn Vorhes
Browse files
Options
Downloads
Patches
Plain Diff
use default react imports
parent
5240e7d8
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
dist/reactComponents/Radio.d.ts
+8
-4
8 additions, 4 deletions
dist/reactComponents/Radio.d.ts
dist/reactComponents/Radio.js.map
+1
-1
1 addition, 1 deletion
dist/reactComponents/Radio.js.map
src/reactComponents/Radio.tsx
+15
-12
15 additions, 12 deletions
src/reactComponents/Radio.tsx
with
24 additions
and
17 deletions
dist/reactComponents/Radio.d.ts
+
8
−
4
View file @
87c7ff14
...
@@ -24,13 +24,17 @@ export declare class Radio extends React.Component<{
...
@@ -24,13 +24,17 @@ export declare class Radio extends React.Component<{
},
{}
>
{
},
{}
>
{
render
():
JSX
.
Element
;
render
():
JSX
.
Element
;
}
}
export
declare
class
RadioConnected
extends
React
.
Component
<
{
interface
iRadioConnectedOpt
{
inline
?:
boolean
;
classes
?:
string
[];
}
interface
iRadioConnected
extends
iRadioConnectedOpt
{
title
:
string
;
title
:
string
;
items
:
string
[];
items
:
string
[];
callback
:
(
val
:
string
)
=>
any
;
callback
:
(
val
:
string
)
=>
any
;
inline
?:
boolean
;
selectedIndex
:
number
;
selectedIndex
:
number
;
classes
?:
string
[];
}
}
,
{}
>
{
export
declare
class
RadioConnected
extends
React
.
Component
<
iRadioConnected
,
{}
>
{
render
():
JSX
.
Element
;
render
():
JSX
.
Element
;
}
}
export
{};
This diff is collapsed.
Click to expand it.
dist/reactComponents/Radio.js.map
+
1
−
1
View file @
87c7ff14
{"version":3,"file":"Radio.js","sourceRoot":"","sources":["../../src/reactComponents/Radio.tsx"],"names":[],"mappings":";AAAA;;GAEG;;AAGH,+BAAgC;AAGhC,qBAAmB;AACnB,+CAAwC;AAiBxC,MAAM,SAAU,SAAQ,KAAK,CAAC,SAAyB;IAGnD,YAAY,KAAiB,EAAE,OAAe;QAC1C,KAAK,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QACtB,IAAI,CAAC,IAAI,GAAG,kBAAQ,EAAE,CAAA;IAC1B,CAAC;IAGD,MAAM;QACF,IAAI,KAAK,GAAG,EAAE,CAAC;QACf,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE;YACnB,KAAK,GAAG;gBACJ,OAAO,EAAE,cAAc;gBACvB,OAAO,EAAE,OAAO;aACnB,CAAC;SACL;QAED,IAAI,KAAK,GAAG;YACR,EAAE,EAAE,IAAI,CAAC,IAAI;YACb,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO;YACxB,KAAK,EAAE,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,IAAI,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE;YAC5F,QAAQ,EAAE,CAAC,GAAkC,EAAE,EAAE;gBAC7C,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBACpC,GAAG,CAAC,MAAM,CAAC,OA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2C;AAC3C,IAAI;AAEJ,qBAAqB;AACrB,qBAAqB;AACrB,uBAAuB;AACvB,sCAAsC;AACtC,wBAAwB;AACxB,0BAA0B;AAC1B,IAAI;AAOJ,MAAa,KAAM,SAAQ,KAAK,CAAC,SAMJ;IAEzB,MAAM;QAEF,OAAO,oBAAC,SAAS,IACb,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,EACvB,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,EACvB,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,EAC7B,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,EACzB,oBAAoB,EAAE,IAAI,CAAC,KAAK,CAAC,YAAY,EAC7C,SAAS,EAAE,KAAK,EAChB,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO,GAC7B,CAAA;IACN,CAAC;CACJ;AApBD,sBAoBC;AAED,MAAa,cAAe,SAAQ,KAAK,CAAC,SAMb;IAEzB,MAAM;QACF,OAAO,oBAAC,SAAS,IACb,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,EACvB,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,EACvB,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,EAC7B,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,EACzB,oBAAoB,EAAE,IAAI,CAAC,KAAK,CAAC,aAAa,EAC9C,SAAS,EAAE,IAAI,EACf,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO,GAC7B,CAAA;IACN,CAAC;CACJ;AAnBD,wCAmBC","sourcesContent":["/**\r\n * Created by glenn on 6/12/2017.\r\n */\r\n\r\n\r\nimport React = require(\"react\");\r\n\r\nimport $ = require('jquery');\r\nimport 'jquery-ui';\r\nimport makeGuid from '../util/makeGuid';\r\nimport {ChangeEvent} from \"react\";\r\n\r\nexport interface iRadioItemOpt {\r\n index?: number\r\n}\r\n\r\nexport interface iRadioItem extends iRadioItemOpt{\r\n groupId: string;\r\n text: string;\r\n checked: boolean;\r\n inline: boolean;\r\n change: (s: string) => any;\r\n connected?: boolean;\r\n\r\n}\r\n\r\nclass RadioItem extends React.Component<iRadioItem, {}> {\r\n guid: string;\r\n\r\n constructor(props: iRadioItem, context: Object){\r\n super(props, context);\r\n this.guid = makeGuid()\r\n }\r\n\r\n\r\n render() {\r\n let style = {};\r\n if (this.props.inline) {\r\n style = {\r\n display: 'inline-block',\r\n padding: '0 5px'\r\n };\r\n }\r\n\r\n let props = {\r\n id: this.guid,\r\n type: \"radio\",\r\n name: this.props.groupId,\r\n value: typeof this.props.index == 'undefined' ? this.props.text : this.props.index.toFixed(),\r\n onChange: (evt: ChangeEvent<HTMLInputElement>) => {\r\n this.props.change(evt.target.value);\r\n evt.target.checked = true;\r\n },\r\n checked: this.props.checked,\r\n defaultChecked: this.props.checked\r\n };\r\n\r\n if (this.props.connected) {\r\n delete props.defaultChecked;\r\n } else {\r\n delete props.checked\r\n }\r\n\r\n return <li style={style}>\r\n <input {...props}/>\r\n <label htmlFor={this.guid}>{this.props.text}</label>\r\n </li>;\r\n }\r\n}\r\n\r\ninterface _iRadioBaseOpt {\r\n inline?: boolean;\r\n classes?: string[];\r\n}\r\n\r\ninterface _iRadioBase extends _iRadioBaseOpt{\r\n title: string;\r\n items: string[];\r\n callback: (val: string) => any;\r\n connected: boolean;\r\n}\r\n\r\ninterface iRadioBase extends _iRadioBase{\r\n selectedValueOrIndex: string|number;\r\n}\r\n\r\nclass RadioBase extends React.Component<iRadioBase, {}> {\r\n inline: boolean;\r\n groupId: string;\r\n\r\n constructor(props: iRadioBase, context: Object) {\r\n super(props, context);\r\n this.inline = this.props.inline || false;\r\n this.groupId = this.props.title.toLowerCase().replace(/ /g, '');\r\n }\r\n\r\n render() {\r\n\r\n let arr = [];\r\n\r\n for (let i = 0; i < this.props.items.length; i++) {\r\n\r\n let itemProps = {\r\n groupId: this.groupId,\r\n text: this.props.items[i],\r\n inline: this.props.inline,\r\n change: (s: string) => (this.props.callback(s)),\r\n key: this.props.items[i],\r\n connected: this.props.connected || false,\r\n checked: false,\r\n index: i\r\n };\r\n\r\n if (typeof this.props.selectedValueOrIndex == 'number'){\r\n itemProps.checked = i == this.props.selectedValueOrIndex;\r\n } else {\r\n itemProps.checked = this.props.items[i] == this.props.selectedValueOrIndex;\r\n delete itemProps.index\r\n }\r\n\r\n arr.push(<RadioItem {...itemProps}/>)\r\n }\r\n\r\n let classes = ['radio-list'];\r\n\r\n if (this.props.classes){\r\n classes = classes.concat(this.props.classes);\r\n }\r\n\r\n return <div className={classes.join(' ')}>\r\n <h4>{this.props.title}</h4>\r\n <ul style={{listStyle: 'none'}}>\r\n {arr}\r\n </ul>\r\n </div>\r\n }\r\n}\r\n\r\n//\r\n// interface _iRadioBaseOpt {\r\n// inline?: boolean;\r\n// classes?: string[];\r\n// }\r\n//\r\n// interface _iRadioBase extends _iRadioBaseOpt{\r\n// title: string;\r\n// items: string[];\r\n// callback: (val: string) => any;\r\n// connected: boolean;\r\n// }\r\n//\r\n// interface iRadioBase extends _iRadioBase{\r\n// selectedValueOrIndex: string|number;\r\n// }\r\n\r\n// interface iRadio {\r\n// title: string;\r\n// items: string[];\r\n// callback: (val: string) => any;\r\n// inline?: boolean;\r\n// classes?: string[];\r\n// }\r\n\r\n\r\n\r\n\r\n\r\n\r\nexport class Radio extends React.Component<{\r\n title: string,\r\n items: string[],\r\n callback: (val: string) => any,\r\n defaultValue: string,\r\n inline?: boolean,\r\n classes?: string[] }, {}> {\r\n\r\n render() {\r\n\r\n return <RadioBase\r\n title={this.props.title}\r\n items={this.props.items}\r\n callback={this.props.callback}\r\n inline={this.props.inline}\r\n selectedValueOrIndex={this.props.defaultValue}\r\n connected={false}\r\n classes={this.props.classes}\r\n />\r\n }\r\n}\r\n\r\nexport class RadioConnected extends React.Component<{\r\n title: string,\r\n items: string[],\r\n callback: (val: string) => any,\r\n inline?: boolean,\r\n selectedIndex: number,\r\n classes?: string[] }, {}> {\r\n\r\n render() {\r\n return <RadioBase\r\n title={this.props.title}\r\n items={this.props.items}\r\n callback={this.props.callback}\r\n inline={this.props.inline}\r\n selectedValueOrIndex={this.props.selectedIndex}\r\n connected={true}\r\n classes={this.props.classes}\r\n />\r\n }\r\n}"]}
{"version":3,"file":"Radio.js","sourceRoot":"","sources":["../../src/reactComponents/Radio.tsx"],"names":[],"mappings":";AAAA;;GAEG;;AAGH,+BAAgC;AAGhC,qBAAmB;AACnB,+CAAwC;AAiBxC,MAAM,SAAU,SAAQ,KAAK,CAAC,SAAyB;IAGnD,YAAY,KAAiB,EAAE,OAAe;QAC1C,KAAK,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QACtB,IAAI,CAAC,IAAI,GAAG,kBAAQ,EAAE,CAAA;IAC1B,CAAC;IAGD,MAAM;QACF,IAAI,KAAK,GAAG,EAAE,CAAC;QACf,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE;YACnB,KAAK,GAAG;gBACJ,OAAO,EAAE,cAAc;gBACvB,OAAO,EAAE,OAAO;aACnB,CAAC;SACL;QAED,IAAI,KAAK,GAAG;YACR,EAAE,EAAE,IAAI,CAAC,IAAI;YACb,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO;YACxB,KAAK,EAAE,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,IAAI,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE;YAC5F,QAAQ,EAAE,CAAC,GAAkC,EAAE,EAAE;gBAC7C,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBACpC,GAAG,CAAC,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC;YAC9B,CAAC;YACD,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC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;AACtC,wBAAwB;AACxB,0BAA0B;AAC1B,IAAI;AAGJ,MAAa,KAAM,SAAQ,KAAK,CAAC,SAMJ;IAEzB,MAAM;QAEF,OAAO,oBAAC,SAAS,IACb,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,EACvB,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,EACvB,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,EAC7B,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,EACzB,oBAAoB,EAAE,IAAI,CAAC,KAAK,CAAC,YAAY,EAC7C,SAAS,EAAE,KAAK,EAChB,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO,GAC7B,CAAA;IACN,CAAC;CACJ;AApBD,sBAoBC;AAcD,MAAa,cAAe,SAAQ,KAAK,CAAC,SAA8B;IAEpE,MAAM;QACF,OAAO,oBAAC,SAAS,IACb,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,EACvB,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,EACvB,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,EAC7B,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,EACzB,oBAAoB,EAAE,IAAI,CAAC,KAAK,CAAC,aAAa,EAC9C,SAAS,EAAE,IAAI,EACf,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO,GAC7B,CAAA;IACN,CAAC;CACJ;AAbD,wCAaC","sourcesContent":["/**\r\n * Created by glenn on 6/12/2017.\r\n */\r\n\r\n\r\nimport React = require(\"react\");\r\n\r\nimport $ = require('jquery');\r\nimport 'jquery-ui';\r\nimport makeGuid from '../util/makeGuid';\r\nimport {ChangeEvent} from \"react\";\r\n\r\nexport interface iRadioItemOpt {\r\n index?: number\r\n}\r\n\r\nexport interface iRadioItem extends iRadioItemOpt{\r\n groupId: string;\r\n text: string;\r\n checked: boolean;\r\n inline: boolean;\r\n change: (s: string) => any;\r\n connected?: boolean;\r\n\r\n}\r\n\r\nclass RadioItem extends React.Component<iRadioItem, {}> {\r\n guid: string;\r\n\r\n constructor(props: iRadioItem, context: Object){\r\n super(props, context);\r\n this.guid = makeGuid()\r\n }\r\n\r\n\r\n render() {\r\n let style = {};\r\n if (this.props.inline) {\r\n style = {\r\n display: 'inline-block',\r\n padding: '0 5px'\r\n };\r\n }\r\n\r\n let props = {\r\n id: this.guid,\r\n type: \"radio\",\r\n name: this.props.groupId,\r\n value: typeof this.props.index == 'undefined' ? this.props.text : this.props.index.toFixed(),\r\n onChange: (evt: ChangeEvent<HTMLInputElement>) => {\r\n this.props.change(evt.target.value);\r\n evt.target.checked = true;\r\n },\r\n checked: this.props.checked,\r\n defaultChecked: this.props.checked\r\n };\r\n\r\n if (this.props.connected) {\r\n delete props.defaultChecked;\r\n } else {\r\n delete props.checked\r\n }\r\n\r\n return <li style={style}>\r\n <input {...props}/>\r\n <label htmlFor={this.guid}>{this.props.text}</label>\r\n </li>;\r\n }\r\n}\r\n\r\ninterface _iRadioBaseOpt {\r\n inline?: boolean;\r\n classes?: string[];\r\n}\r\n\r\ninterface _iRadioBase extends _iRadioBaseOpt{\r\n title: string;\r\n items: string[];\r\n callback: (val: string) => any;\r\n connected: boolean;\r\n}\r\n\r\ninterface iRadioBase extends _iRadioBase{\r\n selectedValueOrIndex: string|number;\r\n}\r\n\r\nclass RadioBase extends React.Component<iRadioBase, {}> {\r\n inline: boolean;\r\n groupId: string;\r\n\r\n constructor(props: iRadioBase, context: Object) {\r\n super(props, context);\r\n this.inline = this.props.inline || false;\r\n this.groupId = this.props.title.toLowerCase().replace(/ /g, '');\r\n }\r\n\r\n render() {\r\n\r\n let arr = [];\r\n\r\n for (let i = 0; i < this.props.items.length; i++) {\r\n\r\n let itemProps = {\r\n groupId: this.groupId,\r\n text: this.props.items[i],\r\n inline: this.props.inline,\r\n change: (s: string) => (this.props.callback(s)),\r\n key: this.props.items[i],\r\n connected: this.props.connected || false,\r\n checked: false,\r\n index: i\r\n };\r\n\r\n if (typeof this.props.selectedValueOrIndex == 'number'){\r\n itemProps.checked = i == this.props.selectedValueOrIndex;\r\n } else {\r\n itemProps.checked = this.props.items[i] == this.props.selectedValueOrIndex;\r\n delete itemProps.index\r\n }\r\n\r\n arr.push(<RadioItem {...itemProps}/>)\r\n }\r\n\r\n let classes = ['radio-list'];\r\n\r\n if (this.props.classes){\r\n classes = classes.concat(this.props.classes);\r\n }\r\n\r\n return <div className={classes.join(' ')}>\r\n <h4>{this.props.title}</h4>\r\n <ul style={{listStyle: 'none'}}>\r\n {arr}\r\n </ul>\r\n </div>\r\n }\r\n}\r\n\r\n//\r\n// interface _iRadioBaseOpt {\r\n// inline?: boolean;\r\n// classes?: string[];\r\n// }\r\n//\r\n// interface _iRadioBase extends _iRadioBaseOpt{\r\n// title: string;\r\n// items: string[];\r\n// callback: (val: string) => any;\r\n// connected: boolean;\r\n// }\r\n//\r\n// interface iRadioBase extends _iRadioBase{\r\n// selectedValueOrIndex: string|number;\r\n// }\r\n\r\n// interface iRadio {\r\n// title: string;\r\n// items: string[];\r\n// callback: (val: string) => any;\r\n// inline?: boolean;\r\n// classes?: string[];\r\n// }\r\n\r\n\r\nexport class Radio extends React.Component<{\r\n title: string,\r\n items: string[],\r\n callback: (val: string) => any,\r\n defaultValue: string,\r\n inline?: boolean,\r\n classes?: string[] }, {}> {\r\n\r\n render() {\r\n\r\n return <RadioBase\r\n title={this.props.title}\r\n items={this.props.items}\r\n callback={this.props.callback}\r\n inline={this.props.inline}\r\n selectedValueOrIndex={this.props.defaultValue}\r\n connected={false}\r\n classes={this.props.classes}\r\n />\r\n }\r\n}\r\n\r\ninterface iRadioConnectedOpt {\r\n inline?: boolean;\r\n classes?: string[];\r\n}\r\n\r\ninterface iRadioConnected extends iRadioConnectedOpt{\r\n title: string;\r\n items: string[];\r\n callback: (val: string) => any;\r\n selectedIndex: number;\r\n}\r\n\r\nexport class RadioConnected extends React.Component<iRadioConnected, {}> {\r\n\r\n render() {\r\n return <RadioBase\r\n title={this.props.title}\r\n items={this.props.items}\r\n callback={this.props.callback}\r\n inline={this.props.inline}\r\n selectedValueOrIndex={this.props.selectedIndex}\r\n connected={true}\r\n classes={this.props.classes}\r\n />\r\n }\r\n}\r\n\r\n"]}
\ No newline at end of file
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/reactComponents/Radio.tsx
+
15
−
12
View file @
87c7ff14
...
@@ -162,10 +162,6 @@ class RadioBase extends React.Component<iRadioBase, {}> {
...
@@ -162,10 +162,6 @@ class RadioBase extends React.Component<iRadioBase, {}> {
// }
// }
export
class
Radio
extends
React
.
Component
<
{
export
class
Radio
extends
React
.
Component
<
{
title
:
string
,
title
:
string
,
items
:
string
[],
items
:
string
[],
...
@@ -188,13 +184,19 @@ export class Radio extends React.Component<{
...
@@ -188,13 +184,19 @@ export class Radio extends React.Component<{
}
}
}
}
export
class
RadioConnected
extends
React
.
Component
<
{
interface
iRadioConnectedOpt
{
title
:
string
,
inline
?:
boolean
;
items
:
string
[],
classes
?:
string
[];
callback
:
(
val
:
string
)
=>
any
,
}
inline
?:
boolean
,
selectedIndex
:
number
,
interface
iRadioConnected
extends
iRadioConnectedOpt
{
classes
?:
string
[]
},
{}
>
{
title
:
string
;
items
:
string
[];
callback
:
(
val
:
string
)
=>
any
;
selectedIndex
:
number
;
}
export
class
RadioConnected
extends
React
.
Component
<
iRadioConnected
,
{}
>
{
render
()
{
render
()
{
return
<
RadioBase
return
<
RadioBase
...
@@ -207,4 +209,5 @@ export class RadioConnected extends React.Component<{
...
@@ -207,4 +209,5 @@ export class RadioConnected extends React.Component<{
classes
=
{
this
.
props
.
classes
}
classes
=
{
this
.
props
.
classes
}
/>
/>
}
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment