mirror of
https://github.com/Ellpeck/ObsidianSimpleTimeTracker.git
synced 2024-11-28 12:08:34 +01:00
Compare commits
No commits in common. "f308679bd2a9474194c50edc8e65676dd8fe5bb4" and "bd7c35e7fb27ff22b58f794c4403c49d4ee3d027" have entirely different histories.
f308679bd2
...
bd7c35e7fb
2 changed files with 37 additions and 21 deletions
|
@ -319,6 +319,7 @@ function addEditableTableRow(tracker: Tracker, entry: Entry, table: HTMLTableEle
|
||||||
|
|
||||||
renderNameAsMarkdown(nameField.label, getFile, component);
|
renderNameAsMarkdown(nameField.label, getFile, component);
|
||||||
|
|
||||||
|
if (entry.subEntries?.length) {
|
||||||
let expandButton = new ButtonComponent(nameField.label)
|
let expandButton = new ButtonComponent(nameField.label)
|
||||||
.setClass("clickable-icon")
|
.setClass("clickable-icon")
|
||||||
.setClass("simple-time-tracker-expand-button")
|
.setClass("simple-time-tracker-expand-button")
|
||||||
|
@ -332,12 +333,12 @@ function addEditableTableRow(tracker: Tracker, entry: Entry, table: HTMLTableEle
|
||||||
}
|
}
|
||||||
await saveTracker(tracker, this.app, getFile(), getSectionInfo());
|
await saveTracker(tracker, this.app, getFile(), getSectionInfo());
|
||||||
});
|
});
|
||||||
if (!entry.subEntries?.length) expandButton.buttonEl.style.visibility = 'hidden';
|
|
||||||
let nameWrapper = nameField.cell.createDiv({cls: "simple-time-tracker-table-expandwrapper"});
|
let nameWrapper = nameField.cell.createDiv({cls: "simple-time-tracker-table-expandwrapper"});
|
||||||
nameWrapper.style.marginLeft = nameField.label.style.marginLeft;
|
nameWrapper.style.marginLeft = nameField.label.style.marginLeft;
|
||||||
nameField.label.style.marginLeft = null;
|
nameField.label.style.marginLeft = null;
|
||||||
nameWrapper.insertBefore(expandButton.buttonEl, null);
|
|
||||||
nameWrapper.insertBefore(nameField.label, null);
|
nameWrapper.insertBefore(nameField.label, null);
|
||||||
|
nameWrapper.insertBefore(expandButton.buttonEl, null);
|
||||||
|
}
|
||||||
|
|
||||||
let entryButtons = row.createEl("td");
|
let entryButtons = row.createEl("td");
|
||||||
entryButtons.addClass("simple-time-tracker-table-buttons");
|
entryButtons.addClass("simple-time-tracker-table-buttons");
|
||||||
|
@ -357,7 +358,6 @@ function addEditableTableRow(tracker: Tracker, entry: Entry, table: HTMLTableEle
|
||||||
.onClick(async () => {
|
.onClick(async () => {
|
||||||
if (nameField.editing()) {
|
if (nameField.editing()) {
|
||||||
entry.name = nameField.endEdit();
|
entry.name = nameField.endEdit();
|
||||||
expandButton.buttonEl.style.display = null;
|
|
||||||
startField.endEdit();
|
startField.endEdit();
|
||||||
entry.startTime = startField.getTimestamp();
|
entry.startTime = startField.getTimestamp();
|
||||||
if (!entryRunning) {
|
if (!entryRunning) {
|
||||||
|
@ -370,7 +370,6 @@ function addEditableTableRow(tracker: Tracker, entry: Entry, table: HTMLTableEle
|
||||||
renderNameAsMarkdown(nameField.label, getFile, component);
|
renderNameAsMarkdown(nameField.label, getFile, component);
|
||||||
} else {
|
} else {
|
||||||
nameField.beginEdit(entry.name);
|
nameField.beginEdit(entry.name);
|
||||||
expandButton.buttonEl.style.display = 'none';
|
|
||||||
// only allow editing start and end times if we don't have sub entries
|
// only allow editing start and end times if we don't have sub entries
|
||||||
if (!entry.subEntries) {
|
if (!entry.subEntries) {
|
||||||
startField.beginEdit(entry.startTime);
|
startField.beginEdit(entry.startTime);
|
||||||
|
|
17
styles.css
17
styles.css
|
@ -79,3 +79,20 @@
|
||||||
.simple-time-tracker-table tr:hover {
|
.simple-time-tracker-table tr:hover {
|
||||||
background-color: var(--background-modifier-hover);
|
background-color: var(--background-modifier-hover);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.simple-time-tracker-table :is(td,th):first-child {
|
||||||
|
/* HACKY hardcoded 2em to make room for expand/collapse button */
|
||||||
|
padding-left: 2em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.simple-time-tracker-table-expandwrapper {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.simple-time-tracker-expand-button {
|
||||||
|
position: absolute;
|
||||||
|
/* HACKY there should be a better way to position this */
|
||||||
|
left: 0;
|
||||||
|
top: 50%;
|
||||||
|
transform: translate(-100%, -50%);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue