Skip to content

Commit

Permalink
#6131 calendar.view.MainContainerModel => calendar.view.MainContainer…
Browse files Browse the repository at this point in the history
…StateProvider
  • Loading branch information
tobiu committed Nov 29, 2024
1 parent 1955fa7 commit 3b8ca6e
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 40 deletions.
2 changes: 1 addition & 1 deletion src/calendar/view/EditEventContainer.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ class EditEventContainer extends FormContainer {
onDeleteButtonClick(data) {
let me = this;

me.getModel().getStore('events').remove(me.record);
me.getStateProvider().getStore('events').remove(me.record);
me.unmount()
}

Expand Down
54 changes: 27 additions & 27 deletions src/calendar/view/MainContainer.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import CalendarsContainer from './calendars/Container.mjs';
import Container from '../../container/Base.mjs';
import DateSelector from '../../component/DateSelector.mjs';
import DateUtil from '../../util/Date.mjs';
import EditCalendarContainer from './calendars/EditContainer.mjs';
import EditEventContainer from './EditEventContainer.mjs';
import MainContainerModel from './MainContainerModel.mjs';
import Toolbar from '../../toolbar/Base.mjs';
import CalendarsContainer from './calendars/Container.mjs';
import Container from '../../container/Base.mjs';
import DateSelector from '../../component/DateSelector.mjs';
import DateUtil from '../../util/Date.mjs';
import EditCalendarContainer from './calendars/EditContainer.mjs';
import EditEventContainer from './EditEventContainer.mjs';
import MainContainerStateProvider from './MainContainerStateProvider.mjs';
import Toolbar from '../../toolbar/Base.mjs';

const todayDate = new Date();

Expand Down Expand Up @@ -102,10 +102,6 @@ class MainContainer extends Container {
* @protected
*/
layout: {ntype: 'vbox', align: 'stretch'},
/**
* @member {Neo.calendar.view.MainContainerModel} model=MainContainerModel
*/
model: MainContainerModel,
/**
* @member {Neo.calendar.view.Component|null} monthComponent=null
*/
Expand Down Expand Up @@ -139,6 +135,10 @@ class MainContainer extends Container {
* @member {Number} sideBarWidth=220
*/
sideBarWidth: 220,
/**
* @member {Neo.calendar.view.MainContainerStateProvider} stateProvider=MainContainerStateProvider
*/
stateProvider: MainContainerStateProvider,
/**
* @member {Boolean} useSettingsContainer_=true
*/
Expand Down Expand Up @@ -326,12 +326,12 @@ class MainContainer extends Container {
let me = this;

me._editCalendarContainer = value = Neo.create({
module : EditCalendarContainer,
appName : me.appName,
model : {parent: me.getModel()},
owner : me,
width : 250,
windowId: me.windowId,
module : EditCalendarContainer,
appName : me.appName,
owner : me,
stateProvider: {parent: me.getStateProvider()},
width : 250,
windowId : me.windowId,
...me.editCalendarContainerConfig
})
}
Expand All @@ -349,12 +349,12 @@ class MainContainer extends Container {
let me = this;

me._editEventContainer = value = Neo.create({
module : EditEventContainer,
appName : me.appName,
model : {parent: me.getModel()},
owner : me,
width : 250,
windowId: me.windowId,
module : EditEventContainer,
appName : me.appName,
owner : me,
stateProvider: {parent: me.getStateProvider()},
width : 250,
windowId : me.windowId,
...me.editEventContainerConfig
})
}
Expand Down Expand Up @@ -600,7 +600,7 @@ class MainContainer extends Container {
* @param {String} data.value
*/
onDateSelectorChange(data) {
data.oldValue !== undefined && this.getModel().setData('currentDate', new Date(`${data.value}T00:00:00.000Z`))
data.oldValue !== undefined && this.getStateProvider().setData('currentDate', new Date(`${data.value}T00:00:00.000Z`))
}

/**
Expand All @@ -621,7 +621,7 @@ class MainContainer extends Container {
* @param data
*/
onTodayButtonClick(data) {
this.model.setData({
this.stateProvider.setData({
currentDate: todayDate
})
}
Expand Down Expand Up @@ -656,7 +656,7 @@ class MainContainer extends Container {

map[me.activeView]();

me.model.setData({currentDate})
me.stateProvider.setData({currentDate})
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import CalendarsStore from '../store/Calendars.mjs';
import ColorsStore from '../store/Colors.mjs';
import EventsStore from '../store/Events.mjs';
import Component from '../../../src/model/Component.mjs';
import StateProvider from '../../../src/state/Provider.mjs';

const todayDate = new Date();

/**
* @class Neo.calendar.view.MainContainerModel
* @extends Neo.model.Component
* @class Neo.calendar.view.MainContainerStateProvider
* @extends Neo.state.Provider
*/
class MainContainerModel extends Component {
class MainContainerStateProvider extends StateProvider {
static config = {
/**
* @member {String} className='Neo.calendar.view.MainContainerModel'
* @member {String} className='Neo.calendar.view.MainContainerStateProvider'
* @protected
*/
className: 'Neo.calendar.view.MainContainerModel',
className: 'Neo.calendar.view.MainContainerStateProvider',
/**
* @member {Object} data
*/
Expand Down Expand Up @@ -168,4 +168,4 @@ class MainContainerModel extends Component {
}
}

export default Neo.setupClass(MainContainerModel);
export default Neo.setupClass(MainContainerStateProvider);
2 changes: 1 addition & 1 deletion src/calendar/view/calendars/EditContainer.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ class EditContainer extends FormContainer {

// todo: we could add a confirm dialog

me.getModel().getStore('calendars').remove(me.record);
me.getStateProvider().getStore('calendars').remove(me.record);
me.unmount();
}

Expand Down
2 changes: 1 addition & 1 deletion src/calendar/view/calendars/List.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class List extends ComponentList {
* @param {String[]} items
*/
onSelect(items) {
this.getModel().setData('activeCalendarId', this.getItemRecordId(items[0]))
this.getStateProvider().setData('activeCalendarId', this.getItemRecordId(items[0]))
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/calendar/view/settings/GeneralContainer.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -273,15 +273,15 @@ class GeneralContainer extends Container {
* @param {Object} data
*/
onDataChange(data) {
this.getModel().setData(data.component.name, data.value)
this.getStateProvider().setData(data.component.name, data.value)
}

/**
* @param {Object} data
*/
onRadioDataChange(data) {
if (data.value) {
this.getModel().setData(data.component.name, data.component.fieldValue)
this.getStateProvider().setData(data.component.name, data.component.fieldValue)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/calendar/view/week/EventDragZone.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ class EventDragZone extends DragZone {
// todo: updating a record field which is included inside a sorter should trigger collection.doSort()
// see: https://github.com/neomjs/neo/issues/2392

owner.getModel().getStore('events').doSort();
owner.getStateProvider().getStore('events').doSort();
owner.updateEvents()
}

Expand Down

0 comments on commit 3b8ca6e

Please sign in to comment.