Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Libriciel
web-DPO
Commits
96a01db2
Commit
96a01db2
authored
Aug 10, 2020
by
Théo GUILLON
Browse files
Correction : suppression article dans la faq avec les annexes
Correction : suppression alert
parent
3137594b
Changes
3
Hide whitespace changes
Inline
Side-by-side
app/Controller/ArticlesController.php
View file @
96a01db2
...
...
@@ -430,12 +430,26 @@ class ArticlesController extends AppController {
$success
=
true
;
$this
->
Article
->
begin
();
$files
=
$this
->
Fichierarticle
->
find
(
'all'
,
[
'conditions'
=>
[
'article_id'
=>
$id
],
'fields'
=>
[
'url'
]
]);
$success
=
$success
&&
false
!==
$this
->
Article
->
deleteAll
([
'id'
=>
$id
'
Article.
id'
=>
$id
]);
if
(
$success
==
true
)
{
$this
->
Article
->
commit
();
foreach
(
$files
as
$file
)
{
$this
->
_deleteFileDisk
(
$file
[
'Fichierarticle'
][
'url'
]);
}
$this
->
Session
->
setFlash
(
__d
(
'article'
,
'article.flashsuccessSuppressionArticleEntite'
),
'flashsuccess'
);
}
else
{
$this
->
Article
->
rollback
();
...
...
app/Model/Article.php
View file @
96a01db2
...
...
@@ -42,8 +42,6 @@ class Article extends AppModel {
]
];
public
$hasOne
=
'Fichier'
;
/**
* hasMany associations
*
...
...
app/View/Articles/edit.ctp
View file @
96a01db2
...
...
@@ -247,8 +247,8 @@ echo $this->element('Fiches/modal/modalErrorExtentionAnnexe', [
});
$
.
fn
.
onAny
=
function
(
cb
){
for
(
var
k
in
this
[
0
])
if
(
k
.
search
(
'
on
'
)
===
0
)
for
(
let
k
in
this
[
0
])
if
(
k
.
search
(
'
on
'
)
===
0
)
this
.
on
(
k
.
slice
(
2
),
function
(
e
){
// Probably there's a better way to call a callback function with right context, $.proxy() ?
cb
.
apply
(
this
,[
e
]);
...
...
@@ -270,10 +270,10 @@ echo $this->element('Fiches/modal/modalErrorExtentionAnnexe', [
});
$
(
'
.dropbox
'
).
on
(
'
drop
'
,
function
(
event
)
{
var
formData
=
new
FormData
(),
let
formData
=
new
FormData
(),
files
=
[];
for
(
var
key
in
event
.
originalEvent
.
dataTransfer
.
files
)
{
for
(
let
key
in
event
.
originalEvent
.
dataTransfer
.
files
)
{
formData
.
append
(
'
fichiers[]
'
,
event
.
originalEvent
.
dataTransfer
.
files
[
key
]);
}
...
...
@@ -285,20 +285,19 @@ echo $this->element('Fiches/modal/modalErrorExtentionAnnexe', [
contentType
:
false
,
success
:
function
(
data
)
{
try
{
var
content
=
JSON
.
parse
(
data
);
for
(
var
key
in
content
)
{
let
content
=
JSON
.
parse
(
data
);
for
(
let
key
in
content
)
{
if
(
content
[
key
].
status
===
"
success
"
)
{
var
tr
=
$
(
'
<tr id="rowArticle
'
+
key
+
'
"></tr>
'
)
let
tr
=
$
(
'
<tr id="rowArticle
'
+
key
+
'
"></tr>
'
)
.
append
(
'
<td class="col-md-1"><i class="fa fa-file-text-o fa-lg"><!----></i></td>
'
)
.
append
(
'
<td class="col-md-9 tdleft">
'
+
content
[
key
].
filename
+
'
</td>
'
)
.
append
(
'
<td class=
\
"col-md-2
\
"><button type="button" class="btn btn-warning" onclick=
\
"deleteFile(
\'
'
+
content
[
key
].
filename
+
'
\'
,
\'
'
+
key
+
'
\'
)
\
"><i class="fa fa-times-circle"><!----></i> Annuler</button></td>
'
)
$
(
'
#render
'
).
find
(
'
tbody
'
).
append
(
tr
);
}
else
{
alert
(
'
totot
'
);
$
(
'
#errorExtentionAnnexe
'
).
modal
(
'
show
'
);
}
}
}
catch
(
e
){
}
catch
(
e
){
alert
(
"
error
"
);
return
;
}
...
...
@@ -311,7 +310,7 @@ echo $this->element('Fiches/modal/modalErrorExtentionAnnexe', [
// Mise en évidence des onglets ayant des erreurs.
$
(
"
div.form-group .error-message
"
).
closest
(
"
div.tab-pane
"
).
each
(
function
(
idx
,
pane
)
{
var
a
=
$
(
"
a[href='#
"
+
$
(
pane
).
attr
(
'
id
'
)
+
"
']
"
);
let
a
=
$
(
"
a[href='#
"
+
$
(
pane
).
attr
(
'
id
'
)
+
"
']
"
);
$
(
a
).
closest
(
"
li
"
).
addClass
(
"
form-error
"
);
$
(
a
).
append
(
"
<span class='fa fa-exclamation-circle fa-danger' aria-hidden='true'><!----></span>
"
);
});
...
...
@@ -326,7 +325,7 @@ echo $this->element('Fiches/modal/modalErrorExtentionAnnexe', [
method
:
'
POST
'
,
data
:
{
filename
:
file
},
success
:
function
()
{
var
row
=
document
.
getElementById
(
"
rowArticle
"
+
key
);
let
row
=
document
.
getElementById
(
"
rowArticle
"
+
key
);
row
.
parentNode
.
removeChild
(
row
);
},
error
:
function
()
{
...
...
@@ -348,7 +347,7 @@ echo $this->element('Fiches/modal/modalErrorExtentionAnnexe', [
urlFile
:
urlFile
},
success
:
function
()
{
var
row
=
document
.
getElementById
(
"
rowArticle
"
+
idFile
);
let
row
=
document
.
getElementById
(
"
rowArticle
"
+
idFile
);
row
.
parentNode
.
removeChild
(
row
);
},
error
:
function
()
{
...
...
Write
Preview
Supports
Markdown
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