Commit 308c6a98 authored by Malcolm Blaney's avatar Malcolm Blaney

Grid module will now display filter row as fixed when the page is

scrolled, along with the header row. Added some more special
characters to Stock module grid filter, '<' and '>' characters can
be used at the start of the input to filter rows based on column
values being less than or greater than the number that follows those
characters, respectively. Moved fixHeaderRow() from Stock module to
Grid module js and made it generic. It's now also used by the Members
module. Made autocomplete fields more consistent by using minLength: 1
across all modules where the source list is local. Summary page can
now optionally skip displaying the outstanding balance for a user.
parent a491c25e
Pipeline #39994077 passed with stage
in 1 minute and 16 seconds
......@@ -72,13 +72,19 @@ class Grid extends Base {
'"",".slick-header.fixed-style","position","fixed"',
'"",".slick-header.fixed-style","top","48px"',
'"",".slick-header.fixed-style","z-index","2"',
'"",".slick-headerrow.fixed-style","position","fixed"',
'"",".slick-headerrow.fixed-style","top","74px"',
'"",".slick-headerrow.fixed-style","z-index","2"',
'"",".slick-headerrow-column input","box-sizing",' .
'"border-box"',
'"",".slick-headerrow-column input","height","100%"',
'"",".slick-headerrow-column input","padding","0"',
'"",".slick-headerrow-column input","width","100%"',
'"",".slick-headerrow-column.ui-state-default","padding",' .
'"1px"',
'"0"',
'"",".slick-headerrow-column.ui-state-default",' .
'"box-sizing","border-box"',
'"",".slick-headerrow-column.ui-state-default","height",' .
'"100%"',
'"",".slick-cell.selected","background-color","#fdffaf"',
'"",".slick-cell > input[type=text]","padding","0"',
'"",".slick-cell > input[type=text]","border","none"',
......
......@@ -195,8 +195,8 @@ class Settings extends Base {
'"",".settings-section","padding","5px"',
'"",".settings-section h2","margin-top","5px"',
'"",".settings fieldset","margin-bottom","5px"',
'"",".settings-info","font-size","0.8em"',
'"",".settings-info","padding-top","2px"'];
'"",".settings-info","font-size","0.9em"',
'"",".settings-info","padding","2px 0 0 5px"'];
$this->AddSiteStyle($site_style);
}
......
......@@ -94,26 +94,28 @@ class Summary extends Base {
$roster = new Roster($this->user, $this->owner);
$volunteer_text = $roster->Description();
$purchase = new Purchase($this->user, $this->owner);
$purchase_total = $purchase->Total();
$payment = new Payment($this->user, $this->owner);
$payment_total = $payment->Total();
$outstanding = $purchase_total - $payment_total;
$outstanding_text = '';
// Ignore small balances, up to ten cents (only for display purposes).
if ($outstanding > 0.1) {
$outstanding_text = 'You currently owe: $' .
number_format($outstanding, 2, '.', '');
$timestamp = $payment->MostRecent();
if ($timestamp !== 0 && time() > $timestamp + 86400) {
$outstanding_text .= $this->Substitute('summary-balance', '/!date/',
date('j F Y', $timestamp));
if ($this->Substitute('summary-display-outstanding') === 'true') {
$purchase = new Purchase($this->user, $this->owner);
$purchase_total = $purchase->Total();
$payment = new Payment($this->user, $this->owner);
$payment_total = $payment->Total();
$outstanding = $purchase_total - $payment_total;
// Ignore small balances, up to ten cents (only for display purposes).
if ($outstanding > 0.1) {
$outstanding_text = 'You currently owe: $' .
number_format($outstanding, 2, '.', '');
$timestamp = $payment->MostRecent();
if ($timestamp !== 0 && time() > $timestamp + 86400) {
$outstanding_text .= $this->Substitute('summary-balance', '/!date/',
date('j F Y', $timestamp));
}
}
else if ($outstanding < -0.1) {
$outstanding_text = 'You are currently in credit by: $' .
number_format($outstanding * -1, 2, '.', '');
}
}
else if ($outstanding < -0.1) {
$outstanding_text = 'You are currently in credit by: $' .
number_format($outstanding * -1, 2, '.', '');
}
return '<p>Hello ' . $name . ',<br>' .
......@@ -189,6 +191,7 @@ class Summary extends Base {
$template = ['"summary-pre-order","","from !open !open-time until ' .
'!final !final-time."',
'"summary-display-outstanding","","true"',
'"summary-balance","","<br>(Payments were last ' .
'processed on !date)"',
'"summary-available-orders","","Select a group:"'];
......@@ -197,6 +200,9 @@ class Summary extends Base {
'summary page specifying when pre-orders are ' .
'finalised. Will replace !final with ' .
'\'pre-order-final\' substitution.',
'summary-display-outstanding' => 'The string true or ' .
'false, used for calculating and displaying any ' .
'outstanding amount on the summary page.',
'summary-balance' => 'Descriptive text to display after ' .
'a negative balance. Substitutes !date for when ' .
'payments were last processed.'];
......
......@@ -25,22 +25,28 @@
// for the JavaScript code in this page.
if(!this.dobrado.grid){dobrado.grid={};}
(function(){'use strict';var list=[];$(function(){if($('.grid').length===0){return;}});dobrado.grid.showColumns=(function(){var totalColumnWidth=0;var columnDisplayWidth=0;var buttonWidth=78;var scrollAmount=0;var initialWidth=0;var wideGrid=false;function showColumnOptions(module){var display='#'+module+'-column-display';var wrapper='#'+module+'-column-wrapper';var columns='#'+module+'-columns';$(display).toggle();if(totalColumnWidth===0){$(columns+' > label').each(function(){totalColumnWidth+=$(this).outerWidth(true);});$(columns).width(totalColumnWidth);}
(function(){'use strict';var list=[];$(function(){if($('.grid').length===0){return;}});dobrado.grid.showColumns=(function(){var totalColumnWidth=0;var columnDisplayWidth=0;var buttonWidth=78;var scrollAmount=0;var initialWidth=0;var wideGrid=false;var gridId='';var headerRow=null;var headerPosition=0;var headerTop='';var filterRow=null;var filterPosition=0;var filterTop='';var previousScroll=0;function showColumnOptions(module){var display='#'+module+'-column-display';var wrapper='#'+module+'-column-wrapper';var columns='#'+module+'-columns';$(display).toggle();if(totalColumnWidth===0){$(columns+' > label').each(function(){totalColumnWidth+=$(this).outerWidth(true);});$(columns).width(totalColumnWidth);}
columnDisplayWidth=$(display).width();$(wrapper).width(columnDisplayWidth-buttonWidth);scrollAmount=columnDisplayWidth-150;}
function showColumnsLeft(module){var columns='#'+module+'-columns';var left=parseInt($(columns).css('margin-left'),10)+scrollAmount;if(left>=0){left=0;$('#'+module+'-column-left').button({disabled:true});}
$('#'+module+'-column-right').button({disabled:false});$(columns).css('margin-left',left+'px');}
function showColumnsRight(module){var columns='#'+module+'-columns';var left=parseInt($(columns).css('margin-left'),10)-scrollAmount;if(left<=columnDisplayWidth-totalColumnWidth-buttonWidth){left=columnDisplayWidth-totalColumnWidth-buttonWidth;$('#'+module+'-column-right').button({disabled:true});}
$('#'+module+'-column-left').button({disabled:false});$(columns).css('margin-left',left+'px');}
function toggleWideGrid(module,grid){function resizeGrid(){if(grid){grid.resizeCanvas();}}
function toggleWideGrid(module,grid){function resizeGrid(){if(grid){grid.resizeCanvas();}
if(headerRow&&headerRow.hasClass('fixed-style')){headerRow.css('width',$(gridId).width()+'px');}
if(filterRow&&filterRow.hasClass('fixed-style')){filterRow.css('width',$(gridId).width()+'px');}}
if(initialWidth===0){initialWidth=$('.'+module).parents('.middle').width();}
if(initialWidth){wideGrid=!wideGrid;if(dobrado.localStorage){localStorage[module+'WideGrid']=JSON.stringify(wideGrid);}
if(wideGrid){$('.middle').width('99%');$(window).on('resize',resizeGrid);}
else{$('.middle').width(initialWidth);$(window).off('resize',resizeGrid);}
resizeGrid();var display='#'+module+'-column-display';var wrapper='#'+module+'-column-wrapper';columnDisplayWidth=$(display).width();$(wrapper).width(columnDisplayWidth-buttonWidth);scrollAmount=columnDisplayWidth-150;if(wideGrid){showColumnsLeft(module);}}}
return function(module,fn,grid){if(fn==='options'){showColumnOptions(module);}
function fixHeader(){var currentScroll=$(window).scrollTop();if(previousScroll<=headerPosition&&currentScroll>headerPosition){headerRow.addClass('fixed-style');filterRow.addClass('fixed-style');headerRow.css('width',$(gridId).width()+'px');filterRow.css('width',$(gridId).width()+'px');if($('.control').css('position')==='static'){headerRow.css('top','0');filterRow.css('top','26px');}}
else if(previousScroll>headerPosition&&currentScroll<=headerPosition){headerRow.removeClass('fixed-style');filterRow.removeClass('fixed-style');headerRow.css('width','100%');filterRow.css('width','100%');if($('.control').css('position')==='static'){headerRow.css('top',headerTop);filterRow.css('top',filterTop);}}
previousScroll=currentScroll;}
return function(module,fn,grid,id){if(fn==='options'){showColumnOptions(module);}
else if(fn==='left'){showColumnsLeft(module);}
else if(fn==='right'){showColumnsRight(module);}
else if(fn==='wide'){toggleWideGrid(module,grid);}};}());dobrado.grid.instance=function(id,rows,columns,options){if(!list[id]){list[id]=new Slick.Grid(id+' .view',rows,columns,options);}
else if(fn==='wide'){gridId=id;toggleWideGrid(module,grid,id);}
else if(fn==='fixed'){gridId=id;headerRow=$(gridId+' .slick-header');headerPosition=headerRow.offset().top;headerTop=headerRow.css('top');filterRow=$(gridId+' .slick-headerrow');filterPosition=filterRow.offset().top;filterTop=filterRow.css('top');previousScroll=0;$(window).scroll(fixHeader);fixHeader();}};}());dobrado.grid.instance=function(id,rows,columns,options){if(!list[id]){list[id]=new Slick.Grid(id+' .view',rows,columns,options);}
return list[id];};}());;(function($){$.fn.drag=function(str,arg,opts){var type=typeof str=="string"?str:"",fn=$.isFunction(str)?str:$.isFunction(arg)?arg:null;if(type.indexOf("drag")!==0)
type="drag"+type;opts=(str==fn?arg:opts)||{};return fn?this.on(type,opts,fn):this.trigger(type);};var $event=$.event,$special=$event.special,drag=$special.drag={defaults:{which:1,distance:0,not:':input',handle:null,relative:false,drop:true,click:false},datakey:"dragdata",noBubble:true,add:function(obj){var data=$.data(this,drag.datakey),opts=obj.data||{};data.related+=1;$.each(drag.defaults,function(key,def){if(opts[key]!==undefined)
data[key]=opts[key];});},remove:function(){$.data(this,drag.datakey).related-=1;},setup:function(){if($.data(this,drag.datakey))
......
......@@ -51,6 +51,15 @@ if (!this.dobrado.grid) {
// Store the initial width of the parent container for the grid.
var initialWidth = 0;
var wideGrid = false;
// These are used by fixHeader which is attached to the scoll event.
var gridId = '';
var headerRow = null;
var headerPosition = 0;
var headerTop = '';
var filterRow = null;
var filterPosition = 0;
var filterTop = '';
var previousScroll = 0;
function showColumnOptions(module) {
// Modules that want to use this feature should create this html:
......@@ -101,6 +110,12 @@ if (!this.dobrado.grid) {
if (grid) {
grid.resizeCanvas();
}
if (headerRow && headerRow.hasClass('fixed-style')) {
headerRow.css('width', $(gridId).width() + 'px');
}
if (filterRow && filterRow.hasClass('fixed-style')) {
filterRow.css('width', $(gridId).width() + 'px');
}
}
// Make sure the module is in the middle section of the layout,
......@@ -137,7 +152,40 @@ if (!this.dobrado.grid) {
}
}
return function(module, fn, grid) {
function fixHeader() {
var currentScroll = $(window).scrollTop();
if (previousScroll <= headerPosition && currentScroll > headerPosition) {
headerRow.addClass('fixed-style');
filterRow.addClass('fixed-style');
// Setting the position as fixed causes the css width rule to no longer
// apply, so set a width based on the grid.
headerRow.css('width', $(gridId).width() + 'px');
filterRow.css('width', $(gridId).width() + 'px');
// When the control bar scrolls with the page, header row should be
// fixed at the top of the page, otherwise the css rule set for
// 'fixed-style' will position the header row under the control bar.
if ($('.control').css('position') === 'static') {
headerRow.css('top', '0');
filterRow.css('top', '26px');
}
}
else if (previousScroll > headerPosition &&
currentScroll <= headerPosition) {
headerRow.removeClass('fixed-style');
filterRow.removeClass('fixed-style');
// Reset the original width rule so wide grid option can still be used.
headerRow.css('width', '100%');
filterRow.css('width', '100%');
// Only need to reset the css rule for top when it's applied above.
if ($('.control').css('position') === 'static') {
headerRow.css('top', headerTop);
filterRow.css('top', filterTop);
}
}
previousScroll = currentScroll;
}
return function(module, fn, grid, id) {
if (fn === 'options') {
showColumnOptions(module);
}
......@@ -148,7 +196,20 @@ if (!this.dobrado.grid) {
showColumnsRight(module);
}
else if (fn === 'wide') {
toggleWideGrid(module, grid);
gridId = id;
toggleWideGrid(module, grid, id);
}
else if (fn === 'fixed') {
gridId = id;
headerRow = $(gridId + ' .slick-header');
headerPosition = headerRow.offset().top;
headerTop = headerRow.css('top');
filterRow = $(gridId + ' .slick-headerrow');
filterPosition = filterRow.offset().top;
filterTop = filterRow.css('top');
previousScroll = 0;
$(window).scroll(fixHeader);
fixHeader();
}
};
}());
......
......@@ -30,7 +30,7 @@ init();});function init(){if($('.groupwizard').parent().hasClass('middle')){$('.
else{var title="Group Settings";if($(".groupwizard-selected-group").length===1){title+=": Updating "+$(".groupwizard-selected-group").html();}
$(".groupwizard").dialog("option","title",title);}
$(".groupwizard .previous").button({disabled:true}).click(previous);$(".groupwizard .next").button().click(next);$("#groupwizard-new-group").button().click(function(){$(".groupwizard-new-group-info").show();$(".groupwizard-existing-group-info").hide();});$("#groupwizard-existing-group").button().click(function(){if($("#groupwizard-existing-group-select").length===0){next();}
else{$(".groupwizard-existing-group-info").show();$(".groupwizard-new-group-info").hide();}});$("#groupwizard-create-group").button().click(createGroup);$('#groupwizard-update-markup').button().click(updateMarkup);$("#groupwizard-existing-group-select").change(changeGroup);$(".groupwizard-purchase-other-order").click(dobrado.account.option);$(".groupwizard-purchase-volunteer").click(dobrado.account.option);$(".groupwizard-invoice-notifications").click(dobrado.account.option);$(".groupwizard-invite").click(dobrado.account.option);$(".account").on("dialogopen",showGroup);$(".account").on("dialogfocus",showGroup);$("#groupwizard-pre-order-open-input").datepicker({dateFormat:dobrado.dateFormat});$("#groupwizard-pre-order-final-input").datepicker({dateFormat:dobrado.dateFormat});$("#groupwizard-co-op-day-input").datepicker({dateFormat:dobrado.dateFormat});$("#groupwizard-invoice-day-input").datepicker({dateFormat:dobrado.dateFormat});$("#groupwizard-invoice-remove-orders-input").datepicker({dateFormat:dobrado.dateFormat});$("#groupwizard-invoice-send-orders-input").datepicker({dateFormat:dobrado.dateFormat});$("#groupwizard-invoice-group-order-input").datepicker({dateFormat:dobrado.dateFormat});$("#groupwizard-update-order-cycle").datepicker({dateFormat:dobrado.dateFormat});$('#groupwizard-timezone').autocomplete({minLength:2,search:dobrado.fixAutoCompleteMemoryLeak,source:timezones()});$(".groupwizard :input").change(save);if($("#groupwizard-pre-order").is(":checked")){$(".groupwizard-pre-order-settings").show();}
else{$(".groupwizard-existing-group-info").show();$(".groupwizard-new-group-info").hide();}});$("#groupwizard-create-group").button().click(createGroup);$('#groupwizard-update-markup').button().click(updateMarkup);$("#groupwizard-existing-group-select").change(changeGroup);$(".groupwizard-purchase-other-order").click(dobrado.account.option);$(".groupwizard-purchase-volunteer").click(dobrado.account.option);$(".groupwizard-invoice-notifications").click(dobrado.account.option);$(".groupwizard-invite").click(dobrado.account.option);$(".account").on("dialogopen",showGroup);$(".account").on("dialogfocus",showGroup);$("#groupwizard-pre-order-open-input").datepicker({dateFormat:dobrado.dateFormat});$("#groupwizard-pre-order-final-input").datepicker({dateFormat:dobrado.dateFormat});$("#groupwizard-co-op-day-input").datepicker({dateFormat:dobrado.dateFormat});$("#groupwizard-invoice-day-input").datepicker({dateFormat:dobrado.dateFormat});$("#groupwizard-invoice-remove-orders-input").datepicker({dateFormat:dobrado.dateFormat});$("#groupwizard-invoice-send-orders-input").datepicker({dateFormat:dobrado.dateFormat});$("#groupwizard-invoice-group-order-input").datepicker({dateFormat:dobrado.dateFormat});$("#groupwizard-update-order-cycle").datepicker({dateFormat:dobrado.dateFormat});$('#groupwizard-timezone').autocomplete({minLength:1,search:dobrado.fixAutoCompleteMemoryLeak,source:timezones()});$(".groupwizard :input").change(save);if($("#groupwizard-pre-order").is(":checked")){$(".groupwizard-pre-order-settings").show();}
if($("#groupwizard-surcharge").is(":checked")){$(".groupwizard-payment-settings").show();}
if($("#groupwizard-stock-order-available").is(":checked")){$("#groupwizard-stock-order-update").parent().show();}
switchInput("pre-order-open");switchInput("pre-order-final");switchInput("co-op-day");switchInput("invoice-day");switchInput("invoice-remove-orders");switchInput("invoice-send-orders");switchInput("invoice-group-order");}
......
......@@ -110,7 +110,7 @@ if (!this.dobrado.groupwizard) {
$("#groupwizard-update-order-cycle").datepicker({
dateFormat: dobrado.dateFormat });
$('#groupwizard-timezone').autocomplete({
minLength: 2,
minLength: 1,
search: dobrado.fixAutoCompleteMemoryLeak,
source: timezones() });
// Save any changes as they are made.
......
......@@ -29,7 +29,7 @@ if(!this.dobrado.manager){dobrado.manager={};}
$('#manager-group-select').change(changeGroup);$('.manager-view-all-dialog').dialog({show:true,autoOpen:false,modal:true,width:830,height:520,position:{my:'top',at:'top+50',of:window},title:'Available Products',create:dobrado.fixedDialog,close:function(){if(allProductsGrid){allProductsGrid.gotoCell(0,0);}}});$('.manager .view-all').button().click(viewAll);$('#manager-form .default-action').click(submit);$('#manager-form .submit').button().click(submit);$('#manager-form .search').button().click(search);$('#manager-form .back').button().click(showPreviousImport);$('#manager-form .remove').button().click(remove);$('#manager-form .import-toggle').click(toggleImport);$('#manager-import-file').change(loadImportData);$('#manager-username-input').val('').change(function(){setTimeout(function(){showUser();},10);});$('#manager-username-input').keypress(checkUsernameEnter);$('#manager-product-input').val('').change(function(){setTimeout(function(){showProductFromMenu();},10);});$('#manager-supplier-input').val('').change(function(){setTimeout(function(){showSupplierFromMenu();},10);});$('#manager-price-input').val('');$('#manager-date-input').val('').change(clearSearchDates).datepicker({dateFormat:dobrado.dateFormat});$('#manager-start-date-input').val('').change(clearDate).datepicker({dateFormat:dobrado.dateFormat});$('#manager-end-date-input').val('').change(clearDate).datepicker({dateFormat:dobrado.dateFormat});$('#manager-quantity-input').val('');$('#manager-quantity-input').spinner({min:0,spin:setQuantity,change:setQuantity});$('.manager .toggle-search-options').click(function(){clearSearchDates();clearDate();$('.manager .search-options').toggle();});if($('.grid').length!==0){gridSetup();}
dobrado.log('Loading users...','info');$.post('/php/request.php',{request:'manager',action:'list',url:location.href,token:dobrado.token},function(response){if(dobrado.checkResponseError(response,'manager list')){return;}
manager=JSON.parse(response);if(manager.date){$('#manager-date-input').datepicker('setDate',dobrado.formatDate(manager.date));}
$('#manager-username-input').autocomplete({minLength:2,search:dobrado.fixAutoCompleteMemoryLeak,source:manager.users,select:showUser});updateProducts();});});function decimalString(value){return(value+0.0001).toFixed(2);}
$('#manager-username-input').autocomplete({minLength:1,search:dobrado.fixAutoCompleteMemoryLeak,source:manager.users,select:showUser});updateProducts();});});function decimalString(value){return(value+0.0001).toFixed(2);}
function gridSetup(){$('.grid').each(function(index){if(index===0){managerGridId='#'+$(this).attr('id');}
if(index===1){allProductsGridId='#'+$(this).attr('id');}});var columns=[{id:'date',name:'Date',field:'date',width:110,sortable:true,formatter:Slick.Formatters.Timestamp},{id:'user',name:'Username',field:'user',width:110,sortable:true},{id:'name',name:'Product',field:'name',width:190,sortable:true},{id:'supplier',name:'Supplier',field:'supplier',width:110,sortable:true}];if($('.dobrado-mobile').is(':hidden')){columns.push({id:'quantity',name:'Qty',field:'quantity',width:60,sortable:true});columns.push({id:'price',name:'Price',field:'price',width:80,sortable:true,formatter:Slick.Formatters.Dollar});columns.push({id:'total',name:'Total',field:'total',width:80,sortable:true,formatter:Slick.Formatters.Dollar});}
var options={autoHeight:true,forceFitColumns:true};managerGrid=dobrado.grid.instance(managerGridId,[],columns,options);managerGrid.setSelectionModel(new Slick.RowSelectionModel());managerGrid.onClick.subscribe(function(e,item){showPurchase(item.row);});managerGrid.onSelectedRowsChanged.subscribe(function(e,item){if(item.rows.length===1){showPurchase(item.rows[0]);}});managerGrid.onSort.subscribe(function(e,args){purchase.sort(function(row1,row2){var field=args.sortCol.field;var sign=args.sortAsc?1:-1;var value1=row1[field];var value2=row2[field];if(field==='quantity'||field==='price'||field==='total'){value1=parseFloat(value1);value2=parseFloat(value2);}
......@@ -71,7 +71,7 @@ $('#manager-price-input').val('');$.each(manager.products,function(index,item){i
else{$('#manager-price-input').val('($'+decimalString(item[priceLevel])+'/'+item.unit+')');$('#manager-price-input').attr('readonly',true);$('#manager-quantity-input').val('').spinner('enable');}
return false;}});}
function updateProducts(){var products=[];var suppliers=[];$.each(manager.products,function(index,item){if($.inArray(item.name,products)===-1){products.push(item.name);}
if($.inArray(item.user,suppliers)===-1){suppliers.push(item.user);}});$('#manager-product-input').autocomplete({minLength:2,search:dobrado.fixAutoCompleteMemoryLeak,source:products,select:showProductFromMenu});$('#manager-supplier-input').autocomplete({minLength:2,search:dobrado.fixAutoCompleteMemoryLeak,source:suppliers,select:showSupplierFromMenu});}
if($.inArray(item.user,suppliers)===-1){suppliers.push(item.user);}});$('#manager-product-input').autocomplete({minLength:1,search:dobrado.fixAutoCompleteMemoryLeak,source:products,select:showProductFromMenu});$('#manager-supplier-input').autocomplete({minLength:1,search:dobrado.fixAutoCompleteMemoryLeak,source:suppliers,select:showSupplierFromMenu});}
function setQuantity(event,ui){var user=$('#manager-username-input').val();var priceLevel='price';if(user!==''){priceLevel=manager.buyerGroup[user];if(!priceLevel){priceLevel='retail';}}
var quantity=0;if('value'in ui){quantity=ui.value;}
else{quantity=parseFloat($(this).val());if(!quantity||quantity<0){quantity=0;$(this).val('0');}}
......
......@@ -139,7 +139,7 @@ if (!this.dobrado.manager) {
$('#manager-date-input').datepicker('setDate',
dobrado.formatDate(manager.date));
}
$('#manager-username-input').autocomplete({ minLength: 2,
$('#manager-username-input').autocomplete({ minLength: 1,
search: dobrado.fixAutoCompleteMemoryLeak,
source: manager.users,
select: showUser });
......@@ -499,11 +499,11 @@ if (!this.dobrado.manager) {
suppliers.push(item.user);
}
});
$('#manager-product-input').autocomplete({ minLength: 2,
$('#manager-product-input').autocomplete({ minLength: 1,
search: dobrado.fixAutoCompleteMemoryLeak,
source: products,
select: showProductFromMenu });
$('#manager-supplier-input').autocomplete({ minLength: 2,
$('#manager-supplier-input').autocomplete({ minLength: 1,
search: dobrado.fixAutoCompleteMemoryLeak,
source: suppliers,
select: showSupplierFromMenu });
......
......@@ -43,8 +43,9 @@ grid=dobrado.grid.instance(id,members.data,columns,options);grid.setSelectionMod
if(value1===value2){continue;}
if(value1>value2){return sign;}
else{return sign* -1;}}
return 0;});grid.invalidate();if(dobrado.localStorage){localStorage.membersSortColumns=JSON.stringify(grid.getSortColumns());}});$('#members-wide-grid').prop('checked',false).click(function(){dobrado.grid.showColumns('members','wide',grid);});if(dobrado.localStorage){if(localStorage.membersWideGrid==='true'){$('#members-wide-grid').click();}
if(localStorage.membersSortColumns){grid.setSortColumns(JSON.parse(localStorage.membersSortColumns));}}}
return 0;});grid.invalidate();if(dobrado.localStorage){localStorage.membersSortColumns=JSON.stringify(grid.getSortColumns());}});$('#members-wide-grid').prop('checked',false).click(function(){dobrado.grid.showColumns('members','wide',grid,id);});if(dobrado.localStorage){if(localStorage.membersWideGrid==='true'){$('#members-wide-grid').click();}
if(localStorage.membersSortColumns){grid.setSortColumns(JSON.parse(localStorage.membersSortColumns));}}
dobrado.grid.showColumns('members','fixed',grid,id);}
function updateColumns(){var columns=[allColumns[0]];var columnIds=['username'];$('#members-columns > input:checked').each(function(){var id=$(this).attr('id').match(/([^-]+)$/)[1];$.each(allColumns,function(i,item){if(item.id===id){columns.push(item);columnIds.push(id);return false;}});});var reload=false;var sort='';if(dobrado.localStorage){var currentColumns=JSON.parse(localStorage.membersColumns);if(currentColumns.length===columnIds.length){return;}
var supplierColumnSelected=$.inArray('supplier',columnIds)!==-1;var activeColumnSelected=$.inArray('active',columnIds)!==-1;if(supplierColumnSelected!==supplierColumn){supplierColumn=supplierColumnSelected;reload=true;}
if(activeColumnSelected!==activeColumn){activeColumn=activeColumnSelected;reload=true;}
......
......@@ -261,7 +261,7 @@ if (!this.dobrado.members) {
}
});
$('#members-wide-grid').prop('checked', false).click(function() {
dobrado.grid.showColumns('members', 'wide', grid);
dobrado.grid.showColumns('members', 'wide', grid, id);
});
if (dobrado.localStorage) {
if (localStorage.membersWideGrid === 'true') {
......@@ -272,6 +272,7 @@ if (!this.dobrado.members) {
grid.setSortColumns(JSON.parse(localStorage.membersSortColumns));
}
}
dobrado.grid.showColumns('members', 'fixed', grid, id);
}
function updateColumns() {
......
......@@ -82,7 +82,7 @@ details=JSON.parse(response);$.each(details.bank,function(key,value){if(value.ac
else{allInactive.push(key);}});var fullname="";var fullnameList=[];$.each(details.contact,function(key,value){fullname="";if(value.first){fullname=dobrado.decode(value.first);}
if(value.last){if(fullname!==""){fullname+=" ";}
fullname+=dobrado.decode(value.last);}
if(fullname!==""){fullnameList.push(fullname);}});$("#payment-username-input").autocomplete({minLength:2,search:dobrado.fixAutoCompleteMemoryLeak,source:allNames,select:usernameUpdate});$("#payment-username-input").change(usernameUpdate);$("#payment-fullname-input").autocomplete({minLength:2,search:dobrado.fixAutoCompleteMemoryLeak,source:fullnameList,select:fullnameUpdate});$("#payment-fullname-input").change(fullnameUpdate);$("#payment-reference-input").autocomplete({minLength:2,search:dobrado.fixAutoCompleteMemoryLeak,source:allReferences,select:referenceUpdate});$("#payment-reference-input").change(referenceUpdate);});}
if(fullname!==""){fullnameList.push(fullname);}});$("#payment-username-input").autocomplete({minLength:1,search:dobrado.fixAutoCompleteMemoryLeak,source:allNames,select:usernameUpdate});$("#payment-username-input").change(usernameUpdate);$("#payment-fullname-input").autocomplete({minLength:1,search:dobrado.fixAutoCompleteMemoryLeak,source:fullnameList,select:fullnameUpdate});$("#payment-fullname-input").change(fullnameUpdate);$("#payment-reference-input").autocomplete({minLength:1,search:dobrado.fixAutoCompleteMemoryLeak,source:allReferences,select:referenceUpdate});$("#payment-reference-input").change(referenceUpdate);});}
function showPayment(item){var fullname="";if(currentImport!==0){exitImport("");}
currentPayment=item;$("#payment-username-input").val(item.name);$("#payment-date-input").val(dobrado.formatDate(item.date));$("#payment-reference-input").val(dobrado.decode(item.reference));$("#payment-amount-input").val(item.amount);$("#payment-comment").val(dobrado.decode(item.comment));$("#payment-fullname-input").val("");clearSearchDates();$.each(details.contact,function(key,value){if(key===item.name){if(value.first){fullname=value.first;}
if(value.last){if(fullname!==""){fullname+=" ";}
......
......@@ -489,17 +489,17 @@ if (!this.dobrado.payment) {
fullnameList.push(fullname);
}
});
$("#payment-username-input").autocomplete({ minLength: 2,
$("#payment-username-input").autocomplete({ minLength: 1,
search: dobrado.fixAutoCompleteMemoryLeak,
source: allNames,
select: usernameUpdate });
$("#payment-username-input").change(usernameUpdate);
$("#payment-fullname-input").autocomplete({ minLength: 2,
$("#payment-fullname-input").autocomplete({ minLength: 1,
search: dobrado.fixAutoCompleteMemoryLeak,
source: fullnameList,
select: fullnameUpdate });
$("#payment-fullname-input").change(fullnameUpdate);
$("#payment-reference-input").autocomplete({ minLength: 2,
$("#payment-reference-input").autocomplete({ minLength: 1,
search: dobrado.fixAutoCompleteMemoryLeak,
source: allReferences,
select: referenceUpdate });
......
......@@ -45,7 +45,7 @@ if(value1>value2){return sign;}
else{return sign* -1;}});accountGrid.invalidate();});}
$('.grid').hide();}
function init(){var products=[];var suppliers=[];$.each(report.products,function(index,item){if($.inArray(item.name,products)===-1){products.push(item.name);}
if($.inArray(item.user,suppliers)===-1){suppliers.push(item.user);}});$('#report-collate-start').datepicker({dateFormat:dobrado.dateFormat}).val('');$('#report-collate-end').datepicker({dateFormat:dobrado.dateFormat}).val('');$('#report-collate-orders').button().click(collateOrders);$('#report-quotas-button').button().click(showQuotas);$('#report-order-download').button().click(showOrder);$('#report-purchase-start').datepicker({dateFormat:dobrado.dateFormat}).val('');$('#report-purchase-end').datepicker({dateFormat:dobrado.dateFormat}).val('');$('#report-purchase-button').button().click(purchaseHistory);$('#report-received-payment-start').datepicker({dateFormat:dobrado.dateFormat}).val('');$('#report-received-payment-end').datepicker({dateFormat:dobrado.dateFormat}).val('');$('#report-received-payment-button').button().click(function(){paymentHistory("received");});$('#report-outgoing-payment-start').datepicker({dateFormat:dobrado.dateFormat}).val('');$('#report-outgoing-payment-end').datepicker({dateFormat:dobrado.dateFormat}).val('');$('#report-outgoing-payment-button').button().click(function(){paymentHistory("outgoing");});$('#report-product').val('').change(function(){setTimeout(function(){showProductFromMenu();},10);});$('#report-product').autocomplete({minLength:2,search:dobrado.fixAutoCompleteMemoryLeak,source:products,select:showProductFromMenu});$('#report-supplier').autocomplete({minLength:2,search:dobrado.fixAutoCompleteMemoryLeak,source:suppliers});$('#report-sales-start').datepicker({dateFormat:dobrado.dateFormat}).val('');$('#report-sales-end').datepicker({dateFormat:dobrado.dateFormat}).val('');$('#report-sales-button').button().click(salesHistory);$('#report-attendance-start').datepicker({dateFormat:dobrado.dateFormat}).val('');$('#report-attendance-end').datepicker({dateFormat:dobrado.dateFormat}).val('');$('#report-attendance-button').button().click(attendanceHistory);$('#report-accounts-select').val('').change(accountOptions);}
if($.inArray(item.user,suppliers)===-1){suppliers.push(item.user);}});$('#report-collate-start').datepicker({dateFormat:dobrado.dateFormat}).val('');$('#report-collate-end').datepicker({dateFormat:dobrado.dateFormat}).val('');$('#report-collate-orders').button().click(collateOrders);$('#report-quotas-button').button().click(showQuotas);$('#report-order-download').button().click(showOrder);$('#report-purchase-start').datepicker({dateFormat:dobrado.dateFormat}).val('');$('#report-purchase-end').datepicker({dateFormat:dobrado.dateFormat}).val('');$('#report-purchase-button').button().click(purchaseHistory);$('#report-received-payment-start').datepicker({dateFormat:dobrado.dateFormat}).val('');$('#report-received-payment-end').datepicker({dateFormat:dobrado.dateFormat}).val('');$('#report-received-payment-button').button().click(function(){paymentHistory("received");});$('#report-outgoing-payment-start').datepicker({dateFormat:dobrado.dateFormat}).val('');$('#report-outgoing-payment-end').datepicker({dateFormat:dobrado.dateFormat}).val('');$('#report-outgoing-payment-button').button().click(function(){paymentHistory("outgoing");});$('#report-product').val('').change(function(){setTimeout(function(){showProductFromMenu();},10);});$('#report-product').autocomplete({minLength:1,search:dobrado.fixAutoCompleteMemoryLeak,source:products,select:showProductFromMenu});$('#report-supplier').autocomplete({minLength:1,search:dobrado.fixAutoCompleteMemoryLeak,source:suppliers});$('#report-sales-start').datepicker({dateFormat:dobrado.dateFormat}).val('');$('#report-sales-end').datepicker({dateFormat:dobrado.dateFormat}).val('');$('#report-sales-button').button().click(salesHistory);$('#report-attendance-start').datepicker({dateFormat:dobrado.dateFormat}).val('');$('#report-attendance-end').datepicker({dateFormat:dobrado.dateFormat}).val('');$('#report-attendance-button').button().click(attendanceHistory);$('#report-accounts-select').val('').change(accountOptions);}
function changeGroup(){dobrado.log('Loading report.','info');$.post('/php/request.php',{request:'report',action:'changeGroup',group:$('#report-group-select').val(),url:location.href,token:dobrado.token},function(response){if(dobrado.checkResponseError(response,'report ChangeGroup')){return;}
report=JSON.parse(response);if(quotaGrid){$(quotaGridId).appendTo('body').hide();}
if(graphId){if(purchaseGraphId){$('#'+purchaseGraphId).parent().hide().appendTo(graphId);}
......
......@@ -226,11 +226,11 @@ if (!this.dobrado.report) {
$('#report-product').val('').change(function() {
setTimeout(function() { showProductFromMenu(); }, 10);
});
$('#report-product').autocomplete({ minLength: 2,
$('#report-product').autocomplete({ minLength: 1,
search: dobrado.fixAutoCompleteMemoryLeak,
source: products,
select: showProductFromMenu });
$('#report-supplier').autocomplete({ minLength: 2,
$('#report-supplier').autocomplete({ minLength: 1,
search: dobrado.fixAutoCompleteMemoryLeak,
source: suppliers });
$('#report-sales-start').datepicker({
......
This diff is collapsed.
......@@ -544,6 +544,18 @@ if (!this.dobrado.stock) {
return false;
}
}
else if (input.indexOf('<') === 0) {
let compare = input.match(/^<\s*([0-9.]+)/);
if (compare && parseFloat(compare[1]) - 0.001 < parseFloat(field)) {
return false;
}
}
else if (input.indexOf('>') === 0) {
let compare = input.match(/^>\s*([0-9.]+)/);
if (compare && parseFloat(compare[1]) + 0.001 > parseFloat(field)) {
return false;
}
}
else if (field.indexOf(input) !== 0) {
return false;
}
......@@ -552,33 +564,6 @@ if (!this.dobrado.stock) {
return true;
}
function fixHeaderRow() {
var currentScroll = $(this).scrollTop();
if (previousScroll <= headerPosition && currentScroll > headerPosition) {
headerRow.addClass('fixed-style');
// Setting the position as fixed causes the css width rule to no longer
// apply, so set a width based on the grid.
headerRow.css('width', $(stockGridId).width() + 'px');
// When the control bar scrolls with the page, header row should be
// fixed at the top of the page, otherwise the default css rule will
// position the header row under the control bar.
if ($('.control').css('position') === 'static') {
headerRow.css('top', '0');
}
}
else if (previousScroll > headerPosition &&
currentScroll <= headerPosition) {
headerRow.removeClass('fixed-style');
// Reset the original width rule so wide grid option can still be used.
headerRow.css('width', '100%');
// Only need to reset the css rule for top when it's applied above.
if ($('.control').css('position') === 'static') {
headerRow.css('top', headerTop);
}
}
previousScroll = currentScroll;
}
var priceName = 'Price';
var availableName = 'Members';
var availableToolTip = 'Available to Members';
......@@ -708,7 +693,7 @@ if (!this.dobrado.stock) {
stockGridView = new Slick.Data.DataView({ inlineFilters: true });
var options = { autoHeight: true, editable: true,
explicitInitialization: true, forceFitColumns: true,
headerRowHeight: 37, multiColumnSort: true,
headerRowHeight: 30, multiColumnSort: true,
showHeaderRow: true };
stockGrid = dobrado.grid.instance(stockGridId, stockGridView, columns,
options);
......@@ -833,7 +818,7 @@ if (!this.dobrado.stock) {
$('#stock-wide-grid').prop('checked', false).checkboxradio({ icon: false }).
click(function() {
dobrado.grid.showColumns('stock', 'wide', stockGrid); });
dobrado.grid.showColumns('stock', 'wide', stockGrid, stockGridId); });
if (dobrado.localStorage) {
if (localStorage.stockWideGrid === 'true') {
// Want to call toggleWideGrid and check the checkbox, this does both.
......@@ -845,12 +830,7 @@ if (!this.dobrado.stock) {
}
// Now that the stock grid is rendered fix the header row to the top of the
// page when scrolled.
var headerRow = $(stockGridId + ' .slick-header');
var headerPosition = headerRow.offset().top;
var headerTop = headerRow.css('top');
var previousScroll = 0;
$(window).scroll(fixHeaderRow);
fixHeaderRow();
dobrado.grid.showColumns('stock', 'fixed', stockGrid, stockGridId);
// If a second grid module is on the page it's used to display
// quantity adjustments.
......
......@@ -30,7 +30,7 @@ else{prev_id=id;prev_placement=placement;prev_order=order;return false;}};}();$(
var attributes=JSON.parse(response);if(attributes.clear&&dobrado.localStorage){localStorage.clear();}
if(attributes.reload){location.reload(true);return;}
if(!attributes.locked){$.each(attributes.list,function(){$(this.id).data('label',this.label);});}
if(attributes.settings){dobrado.moduleSettings=attributes.settings;$.each(dobrado.moduleSettings,function(key,value){if(dobrado[key]&&dobrado[key].settingsCallback){dobrado[key].settingsCallback(value);}});}
if(attributes.settings){dobrado.moduleSettings=attributes.settings;$.each(dobrado.moduleSettings,function(module,settings){if(dobrado[module]&&dobrado[module].settingsCallback){dobrado[module].settingsCallback(settings);}});}
if(attributes.tooltip){dobrado.tooltip(attributes.tooltip.selector,attributes.tooltip.content,attributes.tooltip.arrow);}
if(dobrado.localStorage&&!localStorage.indieConfig){localStorage.indieConfig=JSON.stringify({status:attributes.status});}});$('#page-input').autocomplete({minLength:2,search:dobrado.fixAutoCompleteMemoryLeak,select:changePage,source:pageSearch});CKEDITOR.disableAutoInline=true;var widget=$('<div></div>').addClass('ui-widget-content').hide().appendTo('body');dobrado.arrowBackgroundColor=$('.ui-widget-content').css('background-color');dobrado.arrowBorderColor=$('.ui-widget-content').css('border-bottom-color');widget.remove();$('.logged-in-display-none').css('display','none');if($('.dobrado-mobile').is(':hidden')){$('.sortable').sortable({disabled:true,start:startSort,stop:stopSort,update:updateLayoutPosition,connectWith:'.sortable',placeholder:'ui-sortable-placeholder',opacity:0.6});}});function changePage(event,ui){if(ui){dobrado.changePage(ui.item.value);}}
function pageSearch(request,callback){$.post('/php/search.php',{term:request.term,token:dobrado.token},function(response){callback(JSON.parse(response));});}
......
......@@ -3,7 +3,7 @@
// @licstart The following is the entire license notice
// for the JavaScript code in this page.
//
// Copyright (C) 2017 Malcolm Blaney
// Copyright (C) 2018 Malcolm Blaney
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
......@@ -94,6 +94,6 @@ else if(option==="logout"){logout();}
else if(option==="preferences"||option==="register"||option==="remove-user"){dobrado.log("Loading "+option+" dialog...","info");$.post("/php/request.php",{request:"account",action:option,url:location.href,token:dobrado.token},function(response){if(dobrado.checkResponseError(response,"account request")){return;}
var account=JSON.parse(response);$(".account").html(account.content);if(option==="register"){$("#new-user-input").change(checkUsername);$("#new-user-input").keypress(checkUsernameEnter);$("#account-email-info").click(function(){$(".account-email-check").toggle();return false;});$("#account-set-password").button().click(function(){$("#account-set-password").hide();$(".new-password-wrapper").show();return false;});$("#register-form .submit").button().click(updateUser);$("#new-details-reminder-time").val("").datepicker({dateFormat:dobrado.dateFormat});$('.account').dialog('option','title','Manage Accounts');$('.account').dialog('option','height',500);}
else if(option==="remove-user"){$("#remove-user-form .submit").button().click(removeUser);$('.account').dialog('option','title','Remove Account');$('.account').dialog('option','height',200);}
else if(option==="preferences"){$("#account-tabs").tabs();$("#change-password-form .submit").button().click(changePassword);$("#change-email-form .submit").button().click(changeEmail);$("#group-input").autocomplete({minLength:2,search:dobrado.fixAutoCompleteMemoryLeak,source:account.groups,select:selectGroup});$("#group-input").keypress(loadGroup);$("#account-groups .show-members").button().click(function(){showGroup($("#group-input").val());});$("#user-group-form .submit").button().click(addGroupMember);var tooltip="Current list:<br>";$.each(account.groups,function(i,item){if(item===""){tooltip+="<i>(empty string)</i><br>";}
else{tooltip+=item+"<br>";}});$("label[for=group-input]").tooltip({content:tooltip});$("#user-group-input").autocomplete({minLength:2,search:dobrado.fixAutoCompleteMemoryLeak,source:account.users});$("#user-permission-form .submit").button().click(userPermission);$("#group-permission-form .submit").button().click(groupPermission);$(".account .remove-user-permission").button({icon:'ui-icon-closethick',showLabel:false}).click(removeUserPermission);$(".account .remove-group-permission").button({icon:'ui-icon-closethick',showLabel:false}).click(removeGroupPermission);$('.account').dialog('option','title','Account Preferences');$('.account').dialog('option','height',500);}
else if(option==="preferences"){$("#account-tabs").tabs();$("#change-password-form .submit").button().click(changePassword);$("#change-email-form .submit").button().click(changeEmail);$("#group-input").autocomplete({minLength:1,search:dobrado.fixAutoCompleteMemoryLeak,source:account.groups,select:selectGroup});$("#group-input").keypress(loadGroup);$("#account-groups .show-members").button().click(function(){showGroup($("#group-input").val());});$("#user-group-form .submit").button().click(addGroupMember);var tooltip="Current list:<br>";$.each(account.groups,function(i,item){if(item===""){tooltip+="<i>(empty string)</i><br>";}
else{tooltip+=item+"<br>";}});$("label[for=group-input]").tooltip({content:tooltip});$("#user-group-input").autocomplete({minLength:1,search:dobrado.fixAutoCompleteMemoryLeak,source:account.users});$("#user-permission-form .submit").button().click(userPermission);$("#group-permission-form .submit").button().click(groupPermission);$(".account .remove-user-permission").button({icon:'ui-icon-closethick',showLabel:false}).click(removeUserPermission);$(".account .remove-group-permission").button({icon:'ui-icon-closethick',showLabel:false}).click(removeGroupPermission);$('.account').dialog('option','title','Account Preferences');$('.account').dialog('option','height',500);}
$(".account").dialog("open");});}};}());
\ No newline at end of file
......@@ -124,7 +124,7 @@ function templateHelp(){var label=$('#site-template-label-input').val();if(label
$('#site-template-form .help').tooltip('option','disabled',false);$('#site-template-form .help').tooltip('option','content',description);$('#site-template-form .help').tooltip('open');}
return false;}
function loadTemplates(){$.post('/php/request.php',{request:'extended',mode:'site',action:'templates',url:location.href,token:dobrado.token},function(response){if(dobrado.checkResponseError(response,'site templates')){return;}
template=JSON.parse(response);var templateLabels=[];var templateGroups=[];$.each(template.group,function(group,value){templateGroups.push(group);$.each(value,function(label,content){if($.inArray(label,templateLabels)===-1){templateLabels.push(label);}});});$('#site-template-label-input').change(showTemplateForLabel);$('#site-template-label-input').autocomplete({minLength:2,search:dobrado.fixAutoCompleteMemoryLeak,source:templateLabels,select:showTemplateForLabel});$('#site-template-group-input').change(showTemplateForGroup);$('#site-template-group-input').autocomplete({minLength:2,search:dobrado.fixAutoCompleteMemoryLeak,source:templateGroups,select:showTemplateForGroup});});}
template=JSON.parse(response);var templateLabels=[];var templateGroups=[];$.each(template.group,function(group,value){templateGroups.push(group);$.each(value,function(label,content){if($.inArray(label,templateLabels)===-1){templateLabels.push(label);}});});$('#site-template-label-input').change(showTemplateForLabel);$('#site-template-label-input').autocomplete({minLength:1,search:dobrado.fixAutoCompleteMemoryLeak,source:templateLabels,select:showTemplateForLabel});$('#site-template-group-input').change(showTemplateForGroup);$('#site-template-group-input').autocomplete({minLength:1,search:dobrado.fixAutoCompleteMemoryLeak,source:templateGroups,select:showTemplateForGroup});});}
function updateContent(){var match=$(this).parents('.search-match');var id=match.children('.content').attr('id').match(/^search-match-([0-9]+)$/)[1];var oldContent=searchData[id];var newContent=$('#site-update-textarea').val();dobrado.log('Updating content.','info');$.post('/php/request.php',{request:'extended',mode:'site',action:'updateContent',oldContent:oldContent,newContent:newContent,group:$('#site-search-group-input').val(),url:location.href,token:dobrado.token},function(response){if(dobrado.checkResponseError(response,'site updateContent')){return;}
match.children('.content').html(newContent).show();$('.site-search-update').hide();});return false;}
function updateStyle(){var match=$(this).parents('.search-match');var id=match.children('.content').attr('id').match(/^search-match-([0-9]+)$/)[1];var content=searchData[id];dobrado.log('Updating style.','info');$.post('/php/request.php',{request:'extended',mode:'site',action:'updateStyle',content:content,media:$('#site-update-media').val(),selector:$('#site-update-selector').val(),property:$('#site-update-property').val(),value:$('#site-update-value').val(),group:$('#site-search-group-input').val(),url:location.href,token:dobrado.token},function(response){if(dobrado.checkResponseError(response,'site updateStyle')){return;}});return false;}
......
This diff is collapsed.
......@@ -27,7 +27,7 @@
if(!this.dobrado.organiser){dobrado.organiser={};}
(function(){'use strict';$(function(){if($('.organiser').length===0){return;}
$('#organiser-member-form .submit').button().click(addOrganisationMember);$('#organiser-contact-form .submit').button().click(addOrganisationContact);$('#organiser-email-type-input').val('none-selected').change(changeType);$('#organiser-email-form .add').button().click(addRecipient);$('#organiser-email-form .submit').button().click(sendMessage);$('#organiser-email-subject-input').val('');$('#organiser-email-username-input').val('');$('#organiser-email-to-input').val('');$('#organiser-email-textarea').val('').click(function(){if(!$('.extended').dialog('isOpen')){dobrado.organiser.showEditor();}});dobrado.organiser.showEditor();$.post('/php/request.php',{request:'organiser',action:'show-organisations',url:location.href,token:dobrado.token},function(response){if(dobrado.checkResponseError(response,'show organisations')){return;}
var organiser=JSON.parse(response);$('#organisation-input').autocomplete({minLength:2,search:dobrado.fixAutoCompleteMemoryLeak,source:organiser.list,select:selectOrganisation});$('#organisation-input').keypress(loadOrganisation);var tooltip='Current list:<br>';$.each(organiser.list,function(i,item){if(item===''){tooltip+='<i>(empty string)</i><br>';}
var organiser=JSON.parse(response);$('#organisation-input').autocomplete({minLength:1,search:dobrado.fixAutoCompleteMemoryLeak,source:organiser.list,select:selectOrganisation});$('#organisation-input').keypress(loadOrganisation);var tooltip='Current list:<br>';$.each(organiser.list,function(i,item){if(item===''){tooltip+='<i>(empty string)</i><br>';}
else{tooltip+=item+'<br>';}});$('label[for=organisation-input]').tooltip({content:tooltip});});});function selectOrganisation(event,ui){showOrganisation(ui.item.value);}
function loadOrganisation(event){if(event.keyCode!==13){return;}
event.preventDefault();showOrganisation($(this).val());}
......@@ -46,7 +46,7 @@ function addRecipient(){var current=$('#organiser-email-to-input').val();var nex
$('#organiser-email-to-input').val(current+next);$('#organiser-email-username-input').val('');return false;}
function changeType(){var value=$(this).val();if(value==='none-selected'){$('#organiser-email-form .recipients').hide();$('#organiser-email-to-input').val('');}
else if(value==='individual'){$('#organiser-email-form .recipients').show();$('#organiser-email-to-input').val('');$.post('/php/request.php',{request:'organiser',action:'list-users',url:location.href,token:dobrado.token},function(response){if(dobrado.checkResponseError(response,'organiser list users')){return false;}
var organiser=JSON.parse(response);$('#organiser-email-username-input').autocomplete({minLength:2,search:dobrado.fixAutoCompleteMemoryLeak,source:organiser.list});});}
var organiser=JSON.parse(response);$('#organiser-email-username-input').autocomplete({minLength:1,search:dobrado.fixAutoCompleteMemoryLeak,source:organiser.list});});}
else{$('#organiser-email-form .recipients').hide();$('#organiser-email-to-input').val('Loading...');$.post('/php/request.php',{request:'organiser',action:'list-group',group:value,url:location.href,token:dobrado.token},function(response){if(dobrado.checkResponseError(response,'organiser list group')){$('#organiser-email-to-input').val('');return false;}
var organiser=JSON.parse(response);$('#organiser-email-to-input').val(organiser.list);});}}
function sendMessage(){var recipients=$('#organiser-email-to-input').val();var subject=$('#organiser-email-subject-input').val();var message='';var info='';if(dobrado.editor){message=dobrado.editor.getData();}
......
......@@ -93,9 +93,9 @@ if (!this.dobrado) {
// Want to store all settings so that modules can share them, but
// some modules also need to set options once settings are provided.
dobrado.moduleSettings = attributes.settings;
$.each(dobrado.moduleSettings, function(key, value) {
if (dobrado[key] && dobrado[key].settingsCallback) {
dobrado[key].settingsCallback(value);
$.each(dobrado.moduleSettings, function(module, settings) {
if (dobrado[module] && dobrado[module].settingsCallback) {
dobrado[module].settingsCallback(settings);
}
});
}
......
......@@ -2,7 +2,7 @@
// @licstart The following is the entire license notice
// for the JavaScript code in this page.
//
// Copyright (C) 2017 Malcolm Blaney
// Copyright (C) 2018 Malcolm Blaney
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
......@@ -664,7 +664,7 @@ if (!this.dobrado.account) {
$("#change-email-form .submit").button().click(changeEmail);
// Groups tab.
$("#group-input").autocomplete({ minLength: 2,
$("#group-input").autocomplete({ minLength: 1,
search: dobrado.fixAutoCompleteMemoryLeak,
source: account.groups,
select: selectGroup });
......@@ -683,7 +683,7 @@ if (!this.dobrado.account) {
}
});
$("label[for=group-input]").tooltip({ content: tooltip });
$("#user-group-input").autocomplete({ minLength: 2,
$("#user-group-input").autocomplete({ minLength: 1,
search: dobrado.fixAutoCompleteMemoryLeak,
source: account.users });
......