Skip to content

Commit 8e2a64c

Browse files
committed
Use content list for tag list
1 parent b035f6d commit 8e2a64c

File tree

3 files changed

+97
-102
lines changed

3 files changed

+97
-102
lines changed

css/style.css

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,8 @@ td.ε_row {
244244
}
245245
.page-title {
246246
font-size: 32px;
247+
line-height: 40px;
248+
margin-bottom: 10px;
247249
}
248250
#timetracker-tags {
249251
width: 100%;
@@ -457,4 +459,4 @@ td.ε_row {
457459
.ui-widget-header {
458460
background: var(--color-background-dark);
459461
color: var(--color-text-lighter);
460-
}
462+
}

js/tags.js

Lines changed: 88 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -9,57 +9,56 @@
99
autoOpen: false,
1010
modal: true
1111
});
12-
});
13-
12+
});
13+
1414
$("#new-tag-submit").click(function () {
15-
if ($("#new-tag-input").val().trim() == '')
16-
return false;
15+
if ($("#new-tag-input").val().trim() == '')
16+
return false;
1717
var baseUrl = OC.generateUrl('/apps/timetracker/ajax/add-tag/'+$("#new-tag-input").val());
1818
var jqxhr = $.post( baseUrl, function() {
19-
2019
getTags();
2120
$(dialogTagEditForm).dialog("close");
22-
})
23-
.done(function(data, status, jqXHR) {
24-
var response = data;
25-
if ('Error' in response){
21+
}).done(function(data, status, jqXHR) {
22+
var response = data;
23+
if ('Error' in response){
2624
alert(response.Error);
27-
}
28-
})
29-
.fail(function() {
30-
alert( "error" );
31-
})
32-
return false;
25+
}
26+
}).fail(function() {
27+
alert( "error" );
28+
})
29+
return false;
3330
});
31+
3432
dialogTagEditForm = $( "#dialog-tag-edit-form" ).dialog({
3533
autoOpen: false,
3634
height: 400,
3735
width: 350,
3836
modal: true,
3937
buttons: {
40-
"Edit tag": {click: function(){
41-
editTag(dialogTagEditForm);
42-
return false;
43-
},
44-
text: 'Edit tag',
45-
class:'primary'
46-
},
47-
Cancel: function() {
48-
dialogTagEditForm.dialog( "close" );
49-
}
38+
"Edit tag": {
39+
click: function(){
40+
editTag(dialogTagEditForm);
41+
return false;
42+
},
43+
text: 'Edit tag',
44+
class:'primary'
45+
},
46+
Cancel: function() {
47+
dialogTagEditForm.dialog( "close" );
48+
}
5049
},
5150
close: function() {
52-
form[ 0 ].reset();
51+
form[ 0 ].reset();
5352
}
54-
});
55-
56-
form = dialogTagEditForm.find( "form" ).on( "submit", function( event ) {
53+
});
54+
55+
form = dialogTagEditForm.find( "form" ).on( "submit", function( event ) {
5756
event.preventDefault();
5857
editTag(dialogTagEditForm);
59-
});
58+
});
6059

61-
getTags();
62-
function editTag(dialogTagEditForm){
60+
getTags();
61+
function editTag(dialogTagEditForm){
6362
target = dialogTagEditForm.target;
6463
form = dialogTagEditForm.find( "form" );
6564
var baseUrl = OC.generateUrl('/apps/timetracker/ajax/edit-tag/'+target);
@@ -78,72 +77,66 @@
7877
})
7978

8079
}
81-
function getTags(){
82-
var baseUrl = OC.generateUrl('/apps/timetracker/ajax/tags');
8380

84-
var editIcon = function(cell, formatterParams){ //plain text value
85-
return "<i class='fa fa-edit'></i>";
86-
};
87-
88-
89-
var columns = [
90-
{title:"#", field:"", formatter:"rownum", width: 40, align: "center"},
91-
{title:"Name", field:"name", widthGrow:1}, //column will be allocated 1/5 of the remaining space
92-
{formatter:"buttonCross", width:40, align:"center", cellClick:function(e, cell){
93-
$("#dialog-confirm").dialog({
94-
buttons : {
95-
"Confirm" : {click: function() {
96-
var baseUrl = OC.generateUrl('/apps/timetracker/ajax/delete-tag/'+cell.getRow().getData().id);
97-
var jqxhr = $.post( baseUrl, function() {
98-
getTags();
99-
$("#dialog-confirm").dialog("close");
100-
})
101-
.done(function(data, status, jqXHR) {
102-
var response = data;
103-
if ('Error' in response){
104-
alert(response.Error);
105-
}
106-
})
107-
.fail(function() {
108-
alert( "error" );
109-
})
110-
return false;
111-
},
112-
text: 'Confirm',
113-
class:'primary'
114-
},
115-
"Cancel" : function() {
116-
$(this).dialog("close");
117-
}
118-
}
119-
});
120-
$("#dialog-confirm").dialog('open');
121-
122-
//cell.getRow().delete();
123-
}},
124-
{formatter:editIcon, width:40, align:"center", cellClick:function(e, cell){
81+
function getTags(){
82+
var baseUrl = OC.generateUrl('/apps/timetracker/ajax/tags');
12583

126-
dialogTagEditForm.target = cell.getRow().getData().id;
127-
128-
form = dialogTagEditForm.find( "form" )
129-
form.find("#name").val(cell.getRow().getData().name);
130-
dialogTagEditForm.dialog("open");
84+
var editIcon = function(cell, formatterParams){ //plain text value
85+
return "<i class='fa fa-edit'></i>";
86+
};
13187

132-
}},
133-
];
88+
$.get(baseUrl, function(data){
89+
$('#tags').html('');
90+
var contentList = $('<div/>').addClass('app-content-list');
91+
for (tag of data.Tags) {
92+
console.log(tag);
93+
var listItem = $('<a/>', {href:'#'}).addClass('app-content-list-item');
94+
listItem.append($('<div/>').addClass('app-content-list-item-icon')
95+
.addClass('icon-tag-white')
96+
.css('background-color', 'rgb(100,100,100)'));
97+
listItem.append($('<div/>').addClass('app-content-list-item-line-one').text(tag.name));
98+
listItem.append($('<div/>').addClass('icon-delete').click(function(event){
99+
event.stopPropagation();
100+
$("#dialog-confirm").dialog({
101+
buttons : {
102+
"Confirm" : {click: function() {
103+
var baseUrl = OC.generateUrl('/apps/timetracker/ajax/delete-tag/'+tag.id);
104+
var jqxhr = $.post( baseUrl, function() {
105+
getTags();
106+
$("#dialog-confirm").dialog("close");
107+
})
108+
.done(function(data, status, jqXHR) {
109+
var response = data;
110+
if ('Error' in response){
111+
alert(response.Error);
112+
}
113+
})
114+
.fail(function() {
115+
alert( "error" );
116+
})
117+
return false;
118+
},
119+
text: 'Confirm',
120+
class:'primary'
121+
},
122+
"Cancel" : function() {
123+
$(this).dialog("close");
124+
}
125+
}
126+
});
127+
$("#dialog-confirm").dialog('open');
128+
}));
129+
listItem.click(function(){
130+
dialogTagEditForm.target = tag.id;
134131

135-
var table = new Tabulator("#tags", {
136-
ajaxURL:baseUrl,
137-
layout:"fitColumns",
138-
columns:columns,
139-
rowClick:function(e, row){
140-
return false;
141-
},
142-
ajaxResponse:function(url, params, response){
143-
144-
return response.Tags; //return the tableData property of a response json object
145-
},
146-
});
132+
form = dialogTagEditForm.find( "form" )
133+
form.find("#name").val(tag.name);
134+
dialogTagEditForm.dialog("open");
135+
});
136+
contentList.append(listItem);
137+
}
138+
$('#tags').append(contentList);
139+
});
147140
}
148-
} );
141+
});
149142
}());

templates/content/tags.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<div id="timetracker-tags">
22
<h1 class='page-title'>Tags</h1>
3-
<div id="client-input-container" class='center'>
4-
<form>
5-
<input tabindex="1" type="text" spellcheck="false" autocomplete="off" class="" value="" placeholder="New tag name..." id="new-tag-input">
6-
<input type="submit" value="Add tag" id="new-tag-submit" class='ui-button primary'>
7-
</form>
3+
<div id="client-input-container">
4+
<form>
5+
<input tabindex="1" type="text" spellcheck="false" autocomplete="off" class="" value="" placeholder="New tag name..." id="new-tag-input">
6+
<input type="submit" value="Add tag" id="new-tag-submit" class='ui-button primary'>
7+
</form>
88
</div>
99
<div id="dialog-confirm" title="Confirmation Required" class='hidden'>
1010
Are you sure you want to delete this tag?
@@ -25,4 +25,4 @@
2525
<div class="clearfix"> </div>
2626
<div id="tags">
2727
</div>
28-
</div>
28+
</div>

0 commit comments

Comments
 (0)