diff --git a/src/index-editor.ts.old b/src/index-editor.ts.old deleted file mode 100644 index f216fe2a..00000000 --- a/src/index-editor.ts.old +++ /dev/null @@ -1,1199 +0,0 @@ -import { LitElement, html, TemplateResult, CSSResult } from 'lit'; -import { property, customElement, state } from 'lit/decorators.js'; -import { ScopedRegistryHost } from '@lit-labs/scoped-registry-mixin' -import { HomeAssistant, LovelaceCardEditor, fireEvent } from 'custom-card-helpers'; - -import { localize } from './localize/localize'; -import { style } from './style-editor'; -import { atomicCardConfig } from './types'; -import { formfieldDefinition } from '../elements/formfield'; -import { textfieldDefinition } from '../elements/textfield'; -import { switchDefinition } from '../elements/switch'; -import { selectDefinition } from '../elements/select'; - -const linkTargets: string[] = ['_blank', '_self', '_parent', '_top']; -const defaultModes: string[] = ['Event', 'Calendar']; - -const options = { - required: { - icon: 'tune', - show: false, - }, - main: { - icon: 'eye-settings', - show: false, - }, - event: { - icon: 'calendar-check', - show: false, - }, - calendar: { - icon: 'calendar-month-outline', - show: false, - }, - appearance: { - icon: 'palette', - show: false, - }, -}; - -@customElement('atomic-calendar-revive-editor') -export class AtomicCalendarReviveEditor extends ScopedRegistryHost(LitElement) implements LovelaceCardEditor { - @property({ attribute: false }) - public hass!: HomeAssistant; - @state() private _config!: atomicCardConfig; - @state() private _toggle?: boolean; - @state() private _helpers?: any; - private _initialized = false; - - static elementDefinitions = { - ...textfieldDefinition, - ...formfieldDefinition, - ...switchDefinition, - ...selectDefinition, - }; - - static get styles(): CSSResult { - return style; - } - - public setConfig(config: atomicCardConfig): void { - this._config = config; - - this.loadCardHelpers(); - } - - protected shouldUpdate(): boolean { - if (!this._initialized) { - this._initialize(); - } - - return true; - } - - // ENTITY SETTINGS - get _entityOptions() { - const entities = Object.keys(this.hass.states).filter(eid => eid.substr(0, eid.indexOf('.')) === 'calendar'); - let entityOptions - if (typeof this._config?.entities != 'undefined') { - entityOptions = entities.map(eid => { - let matchingConfigEnitity = this._config?.entities.find(entity => (entity && entity.entity || entity) === eid); - const originalEntity = this.hass.states[eid]; - if (matchingConfigEnitity === undefined) { - - matchingConfigEnitity = { - entity: eid, - name: originalEntity.attributes.friendly_name || eid, - checked: !!matchingConfigEnitity - } - - } else { - if (!('name' in matchingConfigEnitity)) { - matchingConfigEnitity = { ...matchingConfigEnitity, name: (matchingConfigEnitity && matchingConfigEnitity.name) || originalEntity.attributes.friendly_name || eid } - } - matchingConfigEnitity = { ...matchingConfigEnitity, checked: !!matchingConfigEnitity } - - } - return matchingConfigEnitity - }); - } else { - entityOptions = entities.map(eid => { - const originalEntity = this.hass.states[eid]; - return { - entity: eid, - name: originalEntity.attributes.friendly_name || eid, - checked: false - } - }); - } - return entityOptions; - } - - //MAIN SETTINGS - get _name(): string { - return this._config?.name || ''; - } - - get _titleLength(): number { - return this._config?.titleLength || 0; - } - - get _descLength(): number { - return this._config?.descLength || 0; - } - - get _firstDayOfWeek(): number { - return this._config?.firstDayOfWeek || 1; - } - - get _maxDaysToShow(): number { - return this._config?.maxDaysToShow || 7; - } - - get _linkTarget(): string { - return this._config?.linkTarget || '_blank'; - } - get _defaultMode(): string { - return this._config?.defaultMode || 'Event'; - } - get _cardHeight(): string { - return this._config?.cardHeight || '100%'; - } - - get _showLocation(): boolean { - return this._config?.showLocation || true; - } - get _showLoader(): boolean { - return this._config?.showLoader || true; - } - get _sortByStartTime(): boolean { - return this._config?.sortByStartTime || false; - } - get _showDeclined(): boolean { - return this._config?.showDeclined || false; - } - get _hideDuplicates(): boolean { - return this._config?.hideDuplicates || false; - } - get _showMultiDay(): boolean { - return this._config?.showMultiDay || false; - } - get _showMultiDayEventParts(): boolean { - return this._config?.showMultiDayEventParts || false; - } - - get _dateFormat(): string { - return this._config?.dateFormat || 'LL'; - } - get _hoursFormat(): string { - return this._config?.hoursFormat || ''; - } - get _refreshInterval(): number { - return this._config?.refreshInterval || 60; - } - get _showDate(): boolean { - return this._config?.showDate || false; - } - get _showRelativeTime(): boolean { - return this._config?.showRelativeTime || false; - } - get _eventTitle(): string { - return this._config?.eventTitle || ''; - } - get _compactMode(): boolean { - return this._config?.compactMode || false; - } - get _hoursOnSameLine(): boolean { - return this._config?.hoursOnSameLine || false; - } - get _showAllDayEvents(): boolean { - return this._config?.showAllDayEvents || true; - } - get _offsetHeaderDate(): boolean { - return this._config?.offsetHeaderDate || false; - } - - // MAIN SETTINGS END - - // EVENT SETTINGS - - get _showCurrentEventLine(): boolean { - return this._config?.showCurrentEventLine || false; - } - - get _showProgressBar(): boolean { - return this._config?.showProgressBar || true; - - } - - get _showMonth(): boolean { - return this._config?.showMonth || false; - } - get _showWeekDay(): boolean { - return this._config?.showWeekDay || false; - } - get _showDescription(): boolean { - return this._config?.showDescription || true; - } - get _disableEventLink(): boolean { - return this._config?.disableEventLink || false; - } - get _disableLocationLink(): boolean { - return this._config?.disableLocationLink || false; - } - get _showNoEventsForToday(): boolean { - return this._config?.showNoEventsForToday || false; - } - get _showCalNameInEvent(): boolean { - return this._config?.showCalNameInEvent || false; - } - get _showFullDayProgress(): boolean { - return this._config?.showFullDayProgress || false; - } - get _hideFinishedEvents(): boolean { - return this._config?.hideFinishedEvents || false; - } - get _showEventIcon(): boolean { - return this._config?.showEventIcon || false; - } - get _untilText(): string { - return this._config?.untilText || ''; - } - get _fullDayEventText(): string { - return this._config?.fullDayEventText || ''; - } - get _noEventsForNextDaysText(): string { - return this._config?.noEventsForNextDaysText || ''; - } - get _noEventText(): string { - return this._config?.noEventText || ''; - } - get _showHiddenText(): boolean { - return this._config?.showHiddenText || false; - } - get _showCalendarName(): boolean { - return this._config?.showCalendarName || false; - } - get _hiddenEventText(): string { - return this._config?.hiddenEventText || ''; - } - get _showWeekNumber(): boolean { - return this._config?.showWeekNumber || false; - } - get _showEventDate(): boolean { - return this._config?.showEventDate || false; - } - get _showDatePerEvent(): boolean { - return this._config?.showDatePerEvent || false; - } - get _showTimeRemaining(): boolean { - return this._config?.showTimeRemaining || false; - } - - get _showAllDayHours(): boolean { - return this._config?.showTimeRemaining || false; - } - - // EVENT SETTINGS END - - // CALENDAR SETTINGS - get _showLastCalendarWeek(): boolean { - return this._config?.showLastCalendarWeek || false; - } - get _disableCalEventLink(): boolean { - return this._config?.disableCalEventLink || false; - } - get _disableCalLocationLink(): boolean { - return this._config?.disableCalLocationLink || false; - } - get _calShowDescription(): boolean { - return this._config?.calShowDescription || false; - } - - get _disableCalLink(): boolean { - return this._config?.disableCalLink || false; - } - - // CALENDAR SETTINGS END - - // APPEARENCE SETTINGS - - get _locationLinkColor(): string { - return this._config?.locationLinkColor || ''; - } - get _dimFinishedEvents(): boolean { - return this._config?.dimFinishedEvents || true; - } - - // APPEARENCE SETTINGS END - - protected render(): TemplateResult | void { - if (!this.hass || !this._helpers) { - return html``; - } - - // You can restrict on domain type - const entities = Object.keys(this.hass.states).filter(eid => eid.substr(0, eid.indexOf('.')) === 'calendar'); - - return html` -