Skip to content
This repository has been archived by the owner on Jan 5, 2022. It is now read-only.

Commit

Permalink
Fixed #32
Browse files Browse the repository at this point in the history
  • Loading branch information
neuronetio committed Mar 17, 2019
1 parent 0ce2f65 commit 7cb178a
Show file tree
Hide file tree
Showing 14 changed files with 652 additions and 909 deletions.
518 changes: 215 additions & 303 deletions dist/GanttElastic.common.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/GanttElastic.common.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/GanttElastic.common.min.js

Large diffs are not rendered by default.

528 changes: 220 additions & 308 deletions dist/GanttElastic.umd.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/GanttElastic.umd.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/GanttElastic.umd.min.js

Large diffs are not rendered by default.

9 changes: 7 additions & 2 deletions dist/GanttElastic.vuex.common.js

Large diffs are not rendered by default.

9 changes: 7 additions & 2 deletions dist/GanttElastic.vuex.umd.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/bundle.js

Large diffs are not rendered by default.

319 changes: 145 additions & 174 deletions src/GanttElastic.vue

Large diffs are not rendered by default.

21 changes: 17 additions & 4 deletions src/GanttElastic.vuex.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { mergeDeepReactive } from './GanttElastic.vue';
import { mergeDeepReactive, mergeDeep } from './GanttElastic.vue';
const GanttElasticVuexModule = {
state: {
tasks: [],
Expand All @@ -7,7 +7,8 @@ const GanttElasticVuexModule = {
allVisibleTasksHeight: 0,
refs: {},
tasksById: {},
times: {}
times: {},
clientWidth: 0
}
},
mutations: {
Expand Down Expand Up @@ -36,7 +37,19 @@ const GanttElasticVuexModule = {
['GanttElastic/updateOptions'](state, payload) {
state.options = mergeDeepReactive(state.options, payload);
}
},
getters: {
['GanttElastic/options'](state) {
return state.options;
},
['GanttElastic/tasks'](state) {
return state.tasks;
}
}
};
window.GanttElasticVuexModule = GanttElasticVuexModule;
export default GanttElasticVuexModule;
const getStore = state => {
GanttElasticVuexModule.state = state;
return GanttElasticVuexModule;
};
export default getStore;
window.GanttElasticVuexModule = getStore;
124 changes: 31 additions & 93 deletions src/components/Calendar/Calendar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,24 @@
class="gantt-elastic__calendar-wrapper"
:style="root.style('calendar-wrapper', { 'margin-bottom': $store.state.GanttElastic.options.calendar.gap + 'px' })"
>
<div class="gantt-elastic__calendar" :style="root.style('calendar', { width: getWidth + 'px' })">
<div class="gantt-elastic__calendar" :style="root.style('calendar', { width: width + 'px' })">
<calendar-row
:items="$store.state.GanttElastic.options.calendar.months"
:items="months"
which="month"
v-if="$store.state.GanttElastic.options.calendar.month.display"
:style="root.style('calendar-row--month')"
></calendar-row>
<calendar-row
:items="$store.state.GanttElastic.options.calendar.days"
:items="days"
which="day"
v-if="$store.state.GanttElastic.options.calendar.day.display"
:style="root.style('calendar-row--day')"
></calendar-row>
<calendar-row
:items="$store.state.GanttElastic.options.calendar.hours"
:items="hours"
which="hour"
v-if="$store.state.GanttElastic.options.calendar.hour.display"
:style="root.style('calendar-row--hour')"
></calendar-row>
</div>
</div>
Expand All @@ -34,6 +37,7 @@
<script>
import dayjs from 'dayjs';
import CalendarRow from './CalendarRow.vue';
import { mapState } from 'vuex';
export default {
name: 'Calendar',
components: {
Expand All @@ -55,13 +59,6 @@ export default {
this.root.$on('calendar-recalculate', this.regenerate);
},
/**
* Mounted
*/
mounted() {
this.regenerate();
},
methods: {
/**
* How many hours will fit?
Expand Down Expand Up @@ -159,7 +156,7 @@ export default {
}
}
return {
count: 1,
count: 0,
type: formatNames[0]
};
},
Expand Down Expand Up @@ -200,7 +197,7 @@ export default {
generateHours() {
let hours = [];
if (!this.$store.state.GanttElastic.options.calendar.hour.display) {
return this.$store.commit(this.root.updateOptionsMut, { calendar: { hours: [] } });
return hours;
}
for (
let hourIndex = 0, len = this.$store.state.GanttElastic.options.times.steps.length;
Expand All @@ -209,7 +206,7 @@ export default {
) {
const hoursCount = this.howManyHoursFit(hourIndex);
if (hoursCount.count === 0) {
return this.$store.commit(this.root.updateOptionsMut, { calendar: { hours } });
return hours;
}
const hourStep = 24 / hoursCount.count;
const hourWidthPx = this.$store.state.GanttElastic.options.times.steps[hourIndex].width.px / hoursCount.count;
Expand Down Expand Up @@ -238,7 +235,7 @@ export default {
});
}
}
return this.$store.commit(this.root.updateOptionsMut, { calendar: { hours } });
return hours;
},
/**
Expand All @@ -249,11 +246,11 @@ export default {
generateDays() {
let days = [];
if (!this.$store.state.GanttElastic.options.calendar.day.display) {
return this.$store.commit(this.root.updateOptionsMut, { calendar: { days: [] } });
return days;
}
const daysCount = this.howManyDaysFit();
if (daysCount.count === 0) {
return this.$store.commit(this.root.updateOptionsMut, { calendar: { days } });
return days;
}
const dayStep = Math.ceil(this.$store.state.GanttElastic.options.times.steps.length / daysCount.count);
for (
Expand Down Expand Up @@ -286,7 +283,7 @@ export default {
type: daysCount.type
});
}
return this.$store.commit(this.root.updateOptionsMut, { calendar: { days } });
return days;
},
/**
Expand All @@ -297,7 +294,7 @@ export default {
generateMonths() {
let months = [];
if (!this.$store.state.GanttElastic.options.calendar.month.display) {
return this.$store.commit(this.root.updateOptionsMut, { calendar: { months: [] } });
return months;
}
const monthsCount = this.howManyMonthsFit();
let formatNames = Object.keys(this.$store.state.GanttElastic.options.calendar.month.format);
Expand Down Expand Up @@ -350,95 +347,36 @@ export default {
currentDate = dayjs(this.$store.state.GanttElastic.options.times.lastDate);
}
}
return this.$store.commit(this.root.updateOptionsMut, { calendar: { months } });
return months;
},
/**
* Regenerate dates
*/
regenerate() {
this.generateHours();
this.generateDays();
this.generateMonths();
const hours = this.generateHours();
const days = this.generateDays();
const months = this.generateMonths();
this.$store.commit(this.root.updateOptionsMut, { calendar: { hours, days, months } });
this.root.calculateCalendarDimensions();
}
},
computed: {
/**
* Get width
*
* @returns {number}
*/
getWidth() {
let width = this.$store.state.GanttElastic.options.width;
return width;
options() {
return this.$store.getters['GanttElastic/options'];
},
/**
* Get month style
*
* @returns {object}
*/
monthsStyle() {
return this.root.mergeDeep(
{},
this.$store.state.GanttElastic.options.calendar.styles.row,
this.$store.state.GanttElastic.options.calendar.month.style
);
width() {
return this.options.clientWidth;
},
/**
* Get day style
*
* @returns {object}
*/
daysStyle() {
return this.root.mergeDeep(
{},
this.$store.state.GanttElastic.options.calendar.styles.row,
this.$store.state.GanttElastic.options.calendar.day.style
);
days() {
return this.options.calendar.days.filter(day => this.root.isInsideViewPort(day.x, day.width));
},
/**
* Get hour styke
*
* @returns {object}
*/
hoursStyle() {
return this.root.mergeDeep(
{},
this.$store.state.GanttElastic.options.calendar.styles.row,
this.$store.state.GanttElastic.options.calendar.hour.style
);
hours() {
return this.options.calendar.hours.filter(hour => this.root.isInsideViewPort(hour.x, hour.width));
},
/**
* Get visible days
*
* @returns {array}
*/
getDays() {
return this.days.filter(day => this.root.isInsideViewPort(day.x, day.width));
},
/**
* Get visible hours
*
* @returns {array}
*/
getHours() {
return this.hours.filter(hour => this.root.isInsideViewPort(hour.x, hour.width));
},
/**
* Get visible months
*
* @returns {array}
*/
getMonths() {
return this.months.filter(month => this.root.isInsideViewPort(month.x, month.width));
months() {
return this.options.calendar.months.filter(month => this.root.isInsideViewPort(month.x, month.width));
}
}
};
Expand Down
15 changes: 1 addition & 14 deletions src/components/MainView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
class="gantt-elastic__main-container"
:style="
root.style('main-container', {
width: getWidth + 'px',
width: $store.state.GanttElastic.options.clientWidth + 'px',
height: $store.state.GanttElastic.options.height + 'px'
})
"
Expand Down Expand Up @@ -132,19 +132,6 @@ export default {
document.addEventListener('touchend', this.chartMouseUp.bind(this));
},
computed: {
/**
* Get width
*
* @returns {number}
*/
getWidth() {
let width = this.$store.state.GanttElastic.options.clientWidth;
if (width < 0) {
return 0;
}
return width;
},
/**
* Get margin left
*
Expand Down
2 changes: 1 addition & 1 deletion src/components/TaskList/TaskListHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export default {
/**
* Resizer mouse up event handler
*/
resizerMouseUp(event) {
resizerMouseUp() {
if (this.resizer.moving) {
this.root.$emit('taskList-column-width-change', this.resizer.moving);
this.root.$emit('taskList-column-width-change-stop', this.resizer.moving);
Expand Down

0 comments on commit 7cb178a

Please sign in to comment.