-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from mishani0x0ef/#34_provide_more_convenient_…
…way_to_select_spended_time #34 provide more convenient way to select spended time
- Loading branch information
Showing
9 changed files
with
267 additions
and
4 deletions.
There are no files selected for viewing
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,6 @@ | ||
@mixin background-img($url) { | ||
background-image: url($url); | ||
background-size: contain; | ||
background-repeat: no-repeat; | ||
background-position: center; | ||
} |
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,21 @@ | ||
// Colors | ||
|
||
$color-primary: #003366; | ||
|
||
$color-background: #fff; | ||
|
||
$color-text: #333; | ||
|
||
$color-border: #dedede; | ||
|
||
// Images | ||
|
||
$logo-path: "https://raw.githubusercontent.com/mishani0x0ef/ReportJ/master/resources/Icons/logo48x48.png"; | ||
|
||
// Shadows | ||
|
||
$panel-shadow: 0 1px 4px rgba(0,0,0,0.3); | ||
|
||
// Z-Index | ||
|
||
$z-index-base-popup: 1; |
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
18 changes: 18 additions & 0 deletions
18
ReportJ.Extension.Chrome/app/js/content/logTime/logTimeExtender.html
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,18 @@ | ||
<reportj-log-time-extender> | ||
<span class="reportj-link" title="Use ReportJ to set time"></span> | ||
<div class="log-work-popup"> | ||
<div class="popup-section"> | ||
<h4>Hours</h4> | ||
<div class="grid-row hours"></div> | ||
</div> | ||
<div class="popup-section"> | ||
<h4>Minutes</h4> | ||
<div class="grid-row minutes"></div> | ||
</div> | ||
<div class="popup-section buttons-section"> | ||
<span class="product-placement">Powered by ReportJ</span> | ||
<input type="button" id="reportj-submit-log-time" class="aui-button" value="OK" /> | ||
<a id="reportj-cancel-log-time" class="aui-button aui-button-link cancel">Cancel</a> | ||
</div> | ||
</div> | ||
</reportj-log-time-extender> |
110 changes: 110 additions & 0 deletions
110
ReportJ.Extension.Chrome/app/js/content/logTime/logTimeExtender.js
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,110 @@ | ||
import "./logTimeExtender.scss"; | ||
import $ from "jquery"; | ||
import JiraDialogObserver from "~/js/util/jiraDialogObserver"; | ||
import template from "./logTimeExtender.html"; | ||
|
||
export default class LogTimeExtender { | ||
constructor() { | ||
this.componentName = "reportj-log-time-extender"; | ||
this.hours = { | ||
group: "hours", | ||
placeholder: `${this.componentName} .hours`, | ||
values: ["0h", "1h", "2h", "3h", "4h", "5h", "6h", "7h", "8h"] | ||
}; | ||
this.minutes = { | ||
group: "minutes", | ||
placeholder: `${this.componentName} .minutes`, | ||
values: ["0m", "15m", "30m", "45m"] | ||
}; | ||
} | ||
|
||
start() { | ||
this._initLogWorkObserver(); | ||
} | ||
|
||
_initLogWorkObserver() { | ||
const observer = new JiraDialogObserver("Log Work"); | ||
observer.onAppear(($dialog) => { | ||
const $logTimeInput = $dialog.find("#log-work-time-logged"); | ||
const $component = $(template).insertAfter($logTimeInput); | ||
this._initComponentTemplate($component); | ||
this._addButtonHandlers($component); | ||
}); | ||
} | ||
|
||
_initComponentTemplate($template) { | ||
const $link = $template.find(".reportj-link"); | ||
$link.click(() => this._showPopup()); | ||
this._createTimeOptionsGroup(this.hours); | ||
this._createTimeOptionsGroup(this.minutes); | ||
} | ||
|
||
_addButtonHandlers($template) { | ||
const $okButton = $template.find("#reportj-submit-log-time"); | ||
const $cancelButton = $template.find("#reportj-cancel-log-time"); | ||
|
||
$okButton.click(() => { | ||
const time = this._getLogTimeFromPopup(); | ||
this._setLogTimeToJira(time); | ||
this._hidePopup(); | ||
}); | ||
|
||
$cancelButton.click(() => this._hidePopup()); | ||
} | ||
|
||
_showPopup() { | ||
const $logWorkPopup = $(`${this.componentName} .log-work-popup`); | ||
$logWorkPopup.addClass("active"); | ||
} | ||
|
||
_hidePopup() { | ||
const $logWorkPopup = $(`${this.componentName} .log-work-popup`); | ||
$logWorkPopup.removeClass("active"); | ||
} | ||
|
||
_createTimeOptionsGroup(timeOptions) { | ||
const group = timeOptions.group; | ||
const groupSelector = `input[name=${group}]`; | ||
const $elements = timeOptions.values.map((value) => this._createTimeElement(group, value)); | ||
|
||
$(timeOptions.placeholder).append($elements); | ||
$(groupSelector).change((e) => this._onSelctionChange(e)); | ||
} | ||
|
||
_createTimeElement(group, value) { | ||
const inputId = `${group}_${value}`; | ||
return $( | ||
`<div class="grid-cell"> | ||
<input type="radio" id="${inputId}" name="${group}" value="${value}" /> | ||
<label for="${inputId}">${value}</label> | ||
</div>` | ||
); | ||
} | ||
|
||
_onSelctionChange(e) { | ||
const groupName = e.target.name; | ||
const groupSelector = `input[name=${groupName}]`; | ||
const $group = $(groupSelector).parent(); | ||
const activationClass = "active"; | ||
|
||
$group.removeClass(activationClass); | ||
|
||
if (e.target.checked) { | ||
const $targetContainer = $(e.target.parentElement); | ||
$targetContainer.addClass(activationClass); | ||
} | ||
} | ||
|
||
_getLogTimeFromPopup() { | ||
const hoursValue = $(`input[name=${this.hours.group}]:checked`).val() || ""; | ||
const minutesValue = $(`input[name=${this.minutes.group}]:checked`).val() || ""; | ||
const logTime = `${hoursValue} ${minutesValue}`; | ||
|
||
return logTime.trim(); | ||
} | ||
|
||
_setLogTimeToJira(time) { | ||
const $timeInput = $("#log-work-time-logged"); | ||
$timeInput.val(time); | ||
} | ||
} |
92 changes: 92 additions & 0 deletions
92
ReportJ.Extension.Chrome/app/js/content/logTime/logTimeExtender.scss
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,92 @@ | ||
@import "~root/css/variables"; | ||
@import "~root/css/mixins"; | ||
|
||
$link-size: 20px; | ||
|
||
reportj-log-time-extender { | ||
position: relative; | ||
display: inline-flex; | ||
vertical-align: middle; | ||
|
||
h4 { | ||
margin: 0; | ||
} | ||
|
||
.reportj-link { | ||
margin: 0 5px; | ||
width: $link-size; | ||
height: $link-size; | ||
cursor: pointer; | ||
@include background-img($logo-path); | ||
} | ||
|
||
.log-work-popup { | ||
display: none; | ||
background-color: $color-background; | ||
padding: 12px 16px; | ||
box-shadow: $panel-shadow; | ||
|
||
&.active { | ||
position: absolute; | ||
display: flex; | ||
flex-direction: column; | ||
top: 25px; | ||
left: -75px; | ||
z-index: $z-index-base-popup; | ||
} | ||
|
||
.popup-section { | ||
display: flex; | ||
flex-direction: column; | ||
padding-bottom: 12px; | ||
} | ||
|
||
.popup-section:last-of-type { | ||
padding-bottom: 0; | ||
} | ||
|
||
.buttons-section { | ||
display: flex; | ||
flex-direction: row; | ||
align-items: center; | ||
justify-content: flex-end; | ||
|
||
.product-placement { | ||
font-size: 12px; | ||
flex-grow: 1; | ||
} | ||
} | ||
|
||
.grid-row { | ||
display: flex; | ||
border: 1px solid $color-border; | ||
|
||
.grid-cell { | ||
display: flex; | ||
flex-grow: 1; | ||
border-right: 1px solid $color-border; | ||
text-align: center; | ||
|
||
&.active { | ||
font-weight: bold; | ||
background-color: lighten($color-primary, 75%); | ||
} | ||
|
||
input { | ||
display: none; | ||
} | ||
|
||
label { | ||
width: 100%; | ||
height: 100%; | ||
padding: 6px 8px; | ||
color: $color-text; | ||
} | ||
} | ||
|
||
.grid-cell:last-of-type { | ||
border: none; | ||
} | ||
} | ||
} | ||
} |
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