Add refresh to geometry block and watch options to other blocks that need it
This commit is contained in:
@@ -30,23 +30,34 @@ interface CalendarOptionsHeader {
|
||||
hideTitle: boolean;
|
||||
}
|
||||
|
||||
class CalendarOptions {
|
||||
public defaultView = ''
|
||||
public feeds: Array<Feed> = []
|
||||
public header: Partial<CalendarOptionsHeader> = {}
|
||||
public locale = 'en-gb'
|
||||
public refreshRate = 0
|
||||
public showRefresh = false
|
||||
public magnifyOption = ''
|
||||
public eventDisplayOption = 'sameTab'
|
||||
interface Options {
|
||||
defaultView: string;
|
||||
feeds: Array<Feed>;
|
||||
header: Partial<CalendarOptionsHeader>;
|
||||
locale: string;
|
||||
refreshRate: number;
|
||||
showRefresh: boolean;
|
||||
magnifyOption: string;
|
||||
eventDisplayOption: string;
|
||||
}
|
||||
|
||||
const defaults: Readonly<Options> = Object.freeze({
|
||||
defaultView: '',
|
||||
feeds: [],
|
||||
header: {},
|
||||
locale: 'en-gb',
|
||||
refreshRate: 0,
|
||||
showRefresh: false,
|
||||
magnifyOption: '',
|
||||
eventDisplayOption: 'sameTab'
|
||||
})
|
||||
|
||||
/**
|
||||
* Helper class to help define calendar's functionality
|
||||
*/
|
||||
export class PageBlockCalendar extends PageBlock {
|
||||
readonly kind = kind
|
||||
public options = new CalendarOptions()
|
||||
public options: Options = { ...defaults }
|
||||
|
||||
static feedResources = Object.freeze({
|
||||
record: 'compose:record',
|
||||
@@ -55,10 +66,10 @@ export class PageBlockCalendar extends PageBlock {
|
||||
|
||||
constructor (i?: PageBlock | Partial<PageBlock>) {
|
||||
super(i)
|
||||
this.applyOptions(i?.options as Partial<CalendarOptions>)
|
||||
this.applyOptions(i?.options as Partial<Options>)
|
||||
}
|
||||
|
||||
applyOptions (o?: Partial<CalendarOptions>): void {
|
||||
applyOptions (o?: Partial<Options>): void {
|
||||
if (!o) return
|
||||
Apply(this.options, o, Number, 'refreshRate')
|
||||
|
||||
|
||||
@@ -5,10 +5,6 @@ interface FeedOptions {
|
||||
color: string;
|
||||
prefilter: string;
|
||||
moduleID: string;
|
||||
resource: string;
|
||||
titleField: string;
|
||||
displayMarker: boolean;
|
||||
displayPolygon: boolean;
|
||||
}
|
||||
|
||||
export type FeedInput = Partial<Feed> | Feed
|
||||
@@ -17,10 +13,6 @@ const defOptions = {
|
||||
moduleID: NoID,
|
||||
color: '#2f85cb',
|
||||
prefilter: '',
|
||||
resource: 'compose:record',
|
||||
titleField: '',
|
||||
displayMarker: false,
|
||||
displayPolygon: true,
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -29,7 +21,6 @@ const defOptions = {
|
||||
export default class Feed {
|
||||
public resource = 'compose:record'
|
||||
public titleField = ''
|
||||
public color = '#2f85cb'
|
||||
public geometryField = ''
|
||||
public displayMarker = false
|
||||
public displayPolygon = true
|
||||
@@ -43,7 +34,7 @@ export default class Feed {
|
||||
if (!i) return
|
||||
|
||||
if (IsOf<Feed>(i, 'resource')) {
|
||||
Apply(this, i, String, 'resource', 'color', 'titleField', 'geometryField')
|
||||
Apply(this, i, String, 'resource', 'titleField', 'geometryField')
|
||||
Apply(this, i, Boolean, 'displayMarker', 'displayPolygon')
|
||||
|
||||
if (i.options) {
|
||||
|
||||
@@ -16,6 +16,8 @@ interface Options {
|
||||
zoomMax: number;
|
||||
bounds: Bounds | null;
|
||||
lockBounds: boolean;
|
||||
refreshRate: number;
|
||||
showRefresh: boolean;
|
||||
magnifyOption: string;
|
||||
displayOption: string;
|
||||
}
|
||||
@@ -29,6 +31,8 @@ const defaults: Readonly<Options> = Object.freeze({
|
||||
zoomMax: 18,
|
||||
bounds: null,
|
||||
lockBounds: false,
|
||||
refreshRate: 0,
|
||||
showRefresh: false,
|
||||
magnifyOption: '',
|
||||
displayOption: 'sameTab'
|
||||
})
|
||||
@@ -54,8 +58,8 @@ export class PageBlockGeometry extends PageBlock {
|
||||
this.options.bounds = (o.bounds || null)
|
||||
|
||||
Apply(this.options, o, String, 'magnifyOption', 'displayOption')
|
||||
Apply(this.options, o, Number, 'zoomStarting', 'zoomMin', 'zoomMax')
|
||||
Apply(this.options, o, Boolean, 'lockBounds')
|
||||
Apply(this.options, o, Number, 'zoomStarting', 'zoomMin', 'zoomMax', 'refreshRate')
|
||||
Apply(this.options, o, Boolean, 'lockBounds', 'showRefresh')
|
||||
}
|
||||
|
||||
static makeFeed (f?: FeedInput): Feed {
|
||||
|
||||
Reference in New Issue
Block a user