Commit 2ceea91b by Иван Кубота

add disabled dropdown state. add dropdown filter option. change connection lists\logics

parent ba3e05cf
...@@ -4,14 +4,15 @@ const store = window.store = new Store({ ...@@ -4,14 +4,15 @@ const store = window.store = new Store({
conference_id: 'LUCID-4', conference_id: 'LUCID-4',
connection: false, connection: false,
webcamtypes: [ webcamtypes: [
{text: 'Center', value: 'Center'}, {text: 'Center', value: 'Center', filter: 'OfficeUserLeft'},
{text: 'Right', value: 'Right'}, {text: 'Right', value: 'Right', filter: 'RemoteUser'},
{text: 'Left', value: 'Left'}, {text: 'Left', value: 'Left', filter: 'RemoteUser'},
], ],
userRoles: [ userRoles: [
{text: 'Remote User', value: 'RemoteUser'}, {text: 'Remote User', value: 'RemoteUser'},
{text: 'Office User Right', value: 'OfficeUserRight'}, {text: 'Office User', value: 'OfficeUserLeft'},
{text: 'Office User Left', value: 'OfficeUserLeft'}, /*{text: 'Office User Right', value: 'OfficeUserRight'},
{text: 'Office User Left', value: 'OfficeUserLeft'},*/
], ],
}); });
......
...@@ -103,10 +103,10 @@ Screen.Conference = function() { ...@@ -103,10 +103,10 @@ Screen.Conference = function() {
store.set('userRole'+userID, userRoles[userID % userRoles.length].value); store.set('userRole'+userID, userRoles[userID % userRoles.length].value);
var cameraCanvas, canvasResizerEl, var cameraCanvas, canvasResizerEl,
dom = D.div({cls: 'block', style: {marginBottom: '80px'}}, dom = D.div( { cls: 'block', style: { marginBottom: '80px' } },
D.div({cls: 'header'}, 'User '+(currentUserID+1)), D.div( { cls: 'header' }, 'User ' + ( currentUserID + 1 ) ),
canvasResizerEl = CanvasResizer( canvasResizerEl = CanvasResizer(
cameraCanvas = D.h('canvas', { cameraCanvas = D.h( 'canvas', {
cls: "output_canvas", cls: "output_canvas",
width: "640px", width: "640px",
height: "480px", height: "480px",
...@@ -114,12 +114,28 @@ Screen.Conference = function() { ...@@ -114,12 +114,28 @@ Screen.Conference = function() {
/*display: 'none',*/ /*display: 'none',*/
width: '320px' width: '320px'
} }
}) } )
), ),
Select({values: 'userRoles', bind: store.bind('userRole'+userID), label: 'Your role'}), Select( {
Select({values: 'videoinput', bind: store.bind('videoinput'+userID), label: 'Camera device'}), values: 'userRoles',
Select({values: 'webcamtypes', bind: store.bind('webcam'+userID), label: 'Camera position'}) bind: store.bind( 'userRole' + userID ),
label: 'Your role',
disabled: isConnected
} ),
Select( {
values: 'videoinput',
bind: store.bind( 'videoinput' + userID ),
label: 'Camera device',
disabled: isConnected
} ),
Select( {
values: 'webcamtypes',
bind: store.bind( 'webcam' + userID ),
label: 'Camera position',
filter: store.bind( 'userRole' + userID ),
disabled: isConnected
} )
); );
...@@ -228,7 +244,7 @@ Screen.Conference = function() { ...@@ -228,7 +244,7 @@ Screen.Conference = function() {
userID++; userID++;
return dom; return dom;
} }
var usersBlock; var usersBlock, tooMuchUsers = new Store.Value.Boolean(false);
var dom = D.div({cls: 'top-bar'}, var dom = D.div({cls: 'top-bar'},
D.h('img', {src: 'amazon-logo.svg'}), D.h('img', {src: 'amazon-logo.svg'}),
D.div({cls: 'buttons'}, D.div({cls: 'buttons'},
...@@ -247,8 +263,12 @@ Screen.Conference = function() { ...@@ -247,8 +263,12 @@ Screen.Conference = function() {
generateUserUI() generateUserUI()
), ),
D.h('button', {cls: ['button primary', {hidden: isConnected}], D.h('button', {cls: ['button primary', {hidden: Store.OR(isConnected, tooMuchUsers)}],
onclick: ()=> usersBlock.appendChild(generateUserUI()) onclick: ()=> {
usersBlock.appendChild(generateUserUI())
if(userID > 1)
tooMuchUsers.set(true);
}
}, 'Add user'), }, 'Add user'),
......
AddCss('/view/select.css');
var Select = function(cfg) { var Select = function(cfg) {
let isOpen = this.isOpen = new Store.Value.Boolean(false); let isOpen = this.isOpen = new Store.Value.Boolean(false);
let isDisabled = this.isDisabled = cfg.disabled || new Store.Value.Boolean(false);
var table = D.div({cls: 'dropdown-list'}, _=>{ var table = D.div({cls: 'dropdown-list'}, _=>{
store.sub(cfg.values, function(val) { store.sub([cfg.values, cfg.filter], function(val, filter) {
if(val){ if(val){
var possibleValues = [];
_(val.map(function(v) { _(val.map(function(v) {
if(cfg.filter && v.filter !== filter)
return;
possibleValues.push(v);
return D.div({cls: 'dropdown-item', 'data-id': v.value, onclick: function() { return D.div({cls: 'dropdown-item', 'data-id': v.value, onclick: function() {
cfg.bind.set(v.value); cfg.bind.set(v.value);
isOpen.set(false); isOpen.set(false);
}}, v.text) }}, v.text)
})); }));
if(possibleValues.length){
var currentValue = cfg.bind.get();
if( !( possibleValues.find( val => val.value === currentValue ) ) ){
cfg.bind.set( possibleValues[ 0 ].value );
}
}
} }
}); });
}); });
...@@ -18,7 +32,8 @@ var Select = function(cfg) { ...@@ -18,7 +32,8 @@ var Select = function(cfg) {
D.div({cls: 'form-field__label'}, D.div({cls: 'form-field__label'},
D.span({cls: 'form-field__label-text'}, cfg.label), D.span({cls: 'form-field__label-text'}, cfg.label),
D.div({cls: ['dropdown-field', { D.div({cls: ['dropdown-field', {
'dropdown-field--opened': isOpen 'dropdown-field--opened': isOpen,
'dropdown-field--disabled': isDisabled
}]}, }]},
D.h('button', { D.h('button', {
cls: 'dropdown-field__toggler', cls: 'dropdown-field__toggler',
......
.dropdown-field--disabled button.dropdown-field__toggler {
border-bottom: 2px solid#999;
pointer-events: none;
color: #999;
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment