Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
E
esi-table-data
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
esi-data-scrapping
esi-table-data
Commits
8aeeaf06
Commit
8aeeaf06
authored
Jun 02, 2017
by
Vasyl Bodnaruk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add radio buttons for delete export
parent
1c6c92aa
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
57 additions
and
36 deletions
+57
-36
script.js
esi/static/js/script.js
+48
-22
list_news.html
esi/templates/list_news.html
+8
-14
views.py
esi/webapp/views.py
+1
-0
No files found.
esi/static/js/script.js
View file @
8aeeaf06
...
@@ -6,8 +6,10 @@ $(document).ready(function() {
...
@@ -6,8 +6,10 @@ $(document).ready(function() {
// var AJAX_URL = 'https://localhost:3002';
// var AJAX_URL = 'https://localhost:3002';
var
selectAllChk
=
'#select-all'
;
var
selectAllChk
=
'#select-all'
;
var
chk
=
'.checkbox'
;
var
chkExport
=
'.checkbox-export'
;
var
counter
=
'.actions-delete-counter'
;
var
chkDelete
=
'.checkbox-delete'
;
var
counter
=
'.actions-counter'
;
var
counterExport
=
'.actions-export-counter'
;
var
deleteBtn
=
'.js-delete-items'
;
var
deleteBtn
=
'.js-delete-items'
;
var
exportBtn
=
'.js-export-items'
var
exportBtn
=
'.js-export-items'
...
@@ -26,16 +28,16 @@ $(document).ready(function() {
...
@@ -26,16 +28,16 @@ $(document).ready(function() {
return
elementDetails
;
return
elementDetails
;
}
}
function
updateCounter
()
{
function
updateCounter
(
chkBoxSelector
,
button
)
{
var
count
=
0
;
var
count
=
0
;
var
presentSelected
=
$
(
'.checkbox
:checked'
).
length
>
0
?
false
:
true
;
var
presentSelected
=
$
(
chkBoxSelector
+
'
:checked'
).
length
>
0
?
false
:
true
;
var
selectedLength
=
$
(
'.checkbox'
).
each
(
function
(
index
,
item
)
{
var
selectedLength
=
$
(
chkBoxSelector
).
each
(
function
(
index
,
item
)
{
$
(
item
).
prop
(
'checked'
)
===
true
$
(
item
).
prop
(
'checked'
)
===
true
?
count
++
?
count
++
:
''
:
''
});
});
$
(
counter
).
text
(
count
);
$
(
button
).
find
(
counter
).
text
(
count
);
$
(
deleteBt
n
).
prop
(
'disabled'
,
presentSelected
);
$
(
butto
n
).
prop
(
'disabled'
,
presentSelected
);
}
}
function
deleteData
()
{
function
deleteData
()
{
...
@@ -43,9 +45,9 @@ $(document).ready(function() {
...
@@ -43,9 +45,9 @@ $(document).ready(function() {
id
:
[],
id
:
[],
type
:
'deleteAll'
type
:
'deleteAll'
};
};
var
selectedLength
=
$
(
'.checkbox'
).
each
(
function
(
index
,
item
)
{
var
selectedLength
=
$
(
'.checkbox
-delete
'
).
each
(
function
(
index
,
item
)
{
$
(
item
).
prop
(
'checked'
)
===
true
$
(
item
).
prop
(
'checked'
)
===
true
?
items
.
id
.
push
(
$
(
item
).
prop
(
'id'
))
?
items
.
id
.
push
(
$
(
item
).
closest
(
'tr'
).
prop
(
'id'
))
:
''
:
''
});
});
return
items
;
return
items
;
...
@@ -56,9 +58,9 @@ $(document).ready(function() {
...
@@ -56,9 +58,9 @@ $(document).ready(function() {
id
:
[],
id
:
[],
type
:
'exportAll'
type
:
'exportAll'
};
};
var
selectedLength
=
$
(
'.checkbox'
).
each
(
function
(
index
,
item
)
{
var
selectedLength
=
$
(
'.checkbox
-export
'
).
each
(
function
(
index
,
item
)
{
$
(
item
).
prop
(
'checked'
)
===
true
$
(
item
).
prop
(
'checked'
)
===
true
?
items
.
id
.
push
(
$
(
item
).
prop
(
'id'
))
?
items
.
id
.
push
(
$
(
item
).
closest
(
'tr'
).
prop
(
'id'
))
:
''
:
''
});
});
console
.
log
(
items
);
console
.
log
(
items
);
...
@@ -90,28 +92,52 @@ $(document).ready(function() {
...
@@ -90,28 +92,52 @@ $(document).ready(function() {
async
:
true
,
async
:
true
,
contentType
:
"application/json; charset=utf-8"
,
contentType
:
"application/json; charset=utf-8"
,
success
:
function
(
msg
)
{
success
:
function
(
msg
)
{
console
.
log
(
msg
);
var
ids
=
data
.
id
window
.
location
.
replace
(
window
.
location
.
href
);
console
.
log
(
ids
)
if
(
data
.
type
===
'deleteAll'
)
{
removeItems
(
ids
)
updateButtons
()
}
}
})
if
(
data
.
type
===
'exportAll'
)
{
removeItems
(
ids
)
updateButtons
()
}
}
// window.location.reload()
// window.location.replace(window.location.href);
updateCounter
();
}
$
(
selectAllChk
).
click
(
function
()
{
})
$
(
chk
).
prop
(
'checked'
,
$
(
this
).
prop
(
'checked'
));
}
updateCounter
();
function
removeItems
(
ids
)
{
});
ids
.
forEach
(
function
(
item
)
{
$
(
'.form'
).
find
(
'tr'
).
each
(
function
(
index
,
itemRow
)
{
$
(
itemRow
).
attr
(
'id'
)
===
item
?
$
(
itemRow
).
remove
()
:
''
})
})
}
function
updateButtons
()
{
updateCounter
(
chkExport
,
exportBtn
);
updateCounter
(
chkDelete
,
deleteBtn
);
}
updateButtons
()
// $(selectAllChk).click(function () {
// $(chk).prop('checked', $(this).prop('checked'));
// updateCounter();
// });
$
(
chk
).
on
(
'click'
,
updateCounter
);
$
(
chkDelete
).
on
(
'click'
,
updateButtons
);
$
(
chkExport
).
on
(
'click'
,
updateButtons
);
$
(
deleteBtn
).
on
(
'click'
,
function
(
e
)
{
$
(
deleteBtn
).
on
(
'click'
,
function
(
e
)
{
e
.
preventDefault
()
var
data
=
deleteData
();
var
data
=
deleteData
();
ajaxPost
(
'/news/'
,
data
);
ajaxPost
(
'/news/'
,
data
);
});
});
$
(
exportBtn
).
on
(
'click'
,
function
(
e
)
{
$
(
exportBtn
).
on
(
'click'
,
function
(
e
)
{
e
.
preventDefault
()
var
data
=
exportData
();
var
data
=
exportData
();
ajaxPost
(
'/news/'
,
data
);
ajaxPost
(
'/news/'
,
data
);
});
});
...
...
esi/templates/list_news.html
View file @
8aeeaf06
...
@@ -33,10 +33,10 @@
...
@@ -33,10 +33,10 @@
<div>
<div>
<a
href=
"/"
class=
"btn btn-primary"
>
Add
</a>
<a
href=
"/"
class=
"btn btn-primary"
>
Add
</a>
<button
class=
"js-delete-items btn btn-danger"
>
<button
class=
"js-delete-items btn btn-danger"
>
<span>
Delete(
</span><span
class=
"actions-
delete-
counter"
>
0
</span><span>
)
</span>
<span>
Delete(
</span><span
class=
"actions-counter"
>
0
</span><span>
)
</span>
</button>
</button>
<button
class=
"js-export-items btn btn-success"
>
<button
class=
"js-export-items btn btn-success"
>
<span>
Export(
</span><span
class=
"actions-
delete-
counter"
>
0
</span><span>
)
</span>
<span>
Export(
</span><span
class=
"actions-counter"
>
0
</span><span>
)
</span>
</button>
</button>
</div>
</div>
...
@@ -72,7 +72,7 @@
...
@@ -72,7 +72,7 @@
</thead>
</thead>
<tbody>
<tbody>
{% for i in news %}
{% for i in news %}
<tr>
<tr
id=
"{{ i.id }}"
>
<td>
<td>
<span><a
href=
"{% url 'view_news' i.id %}"
>
{{ i.title }}
</a></span>
<span><a
href=
"{% url 'view_news' i.id %}"
>
{{ i.title }}
</a></span>
<div
class=
"action-block"
>
<div
class=
"action-block"
>
...
@@ -82,9 +82,9 @@
...
@@ -82,9 +82,9 @@
<a
href=
"{% url 'edit_news' i.id %}"
data-type=
"edit"
<a
href=
"{% url 'edit_news' i.id %}"
data-type=
"edit"
class=
"action-block-edit"
><strong>
Edit
</strong></a>
class=
"action-block-edit"
><strong>
Edit
</strong></a>
<span
class=
"divider"
>
|
</span>
<span
class=
"divider"
>
|
</span>
<
a
href=
"#"
data-type=
"delete"
class=
"action-block-delete"
><strong>
Delete
</strong></a
>
<
span
class=
"action-block-delete"
><input
id=
"{{ i.id }}_d"
class=
"checkbox-delete"
name=
"{{ i.id }}"
type=
"radio"
><label
for=
"{{ i.id }}_d"
><strong>
Delete
</strong></label></span
>
<span
class=
"divider"
>
|
</span>
<span
class=
"divider"
>
|
</span>
<span
class=
"action-block-edit"
><input
id=
"{{ i.id }}
"
class=
"checkbox"
type=
"checkbox"
><strong>
Export
</strong
></span>
<span
class=
"action-block-edit"
><input
id=
"{{ i.id }}
_e"
class=
"checkbox-export"
name=
"{{ i.id }}"
type=
"radio"
checked
><label
for=
"{{ i.id }}_e"
><strong>
Export
</strong></label
></span>
</div>
</div>
</td>
</td>
<td>
{{ i.get_media }}
</td>
<td>
{{ i.get_media }}
</td>
...
@@ -96,15 +96,9 @@
...
@@ -96,15 +96,9 @@
</tbody>
</tbody>
</table>
</table>
</form>
</form>
<
!--<div class="pagination" align="right">--
>
<
div
style=
"text-align:center"
>
<!--{% show_pages %}-->
{% show_pages %}
<
!--</div>--
>
<
/div
>
{% get_pages %}
<ul
class=
"pagination"
>
{% for page in pages %}
<li><a
href=
"{{ page.url }}"
>
{{ page.number }}
</a></li>
{% endfor %}
</ul>
{% endblock %}
{% endblock %}
\ No newline at end of file
esi/webapp/views.py
View file @
8aeeaf06
...
@@ -60,6 +60,7 @@ class ListNewsView(ListView):
...
@@ -60,6 +60,7 @@ class ListNewsView(ListView):
for
i
in
News
.
objects
.
filter
(
pk__in
=
ids
):
for
i
in
News
.
objects
.
filter
(
pk__in
=
ids
):
i
.
export_news
()
i
.
export_news
()
return
HttpResponse
(
200
)
return
HttpResponse
(
200
)
return
HttpResponse
(
200
)
def
paginate
(
self
,
query
,
page
):
def
paginate
(
self
,
query
,
page
):
paginator
=
Paginator
(
query
,
25
)
paginator
=
Paginator
(
query
,
25
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment