-
Notifications
You must be signed in to change notification settings - Fork 242
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor PeriodDeltaChain to move into webpack compilation
- Loading branch information
1 parent
369bd9c
commit dfa85ec
Showing
13 changed files
with
44 additions
and
79 deletions.
There are no files selected for viewing
57 changes: 0 additions & 57 deletions
57
app/assets/javascripts/PeriodDeltaChain/PeriodDeltaChain.js
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** PeriodDeltaChain Class */ | ||
import dayjs from "dayjs"; | ||
|
||
export default class PeriodDeltaChain { | ||
constructor(params) { | ||
this.period_root_id = params.period_root_id; | ||
this.date_format = params.date_format || ""; | ||
this.period_class = params.period_class || "period"; | ||
|
||
this.set_due_date(params.due_date); | ||
} | ||
|
||
refresh() { | ||
let current_time = this.due_date; | ||
const format = this.date_format; | ||
const period_rows = document | ||
.getElementById(this.period_root_id) | ||
.getElementsByClassName(this.period_class); | ||
|
||
for (let row of period_rows) { | ||
const from_time_node = row.getElementsByClassName("PeriodDeltaChain_FromTime")[0]; | ||
from_time_node.textContent = current_time.format(format); | ||
|
||
const hours_value = row.getElementsByClassName("PeriodDeltaChain_Hours")[0].value; | ||
current_time = current_time.add(hours_value, "hours"); | ||
const to_time_node = row.getElementsByClassName("PeriodDeltaChain_ToTime")[0]; | ||
to_time_node.textContent = current_time.format(format); | ||
} | ||
} | ||
|
||
set_due_date(new_due_date) { | ||
this.due_date = dayjs(new_due_date, this.date_format); | ||
this.refresh(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters