Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
immerda
Immerda Apps
users
Commits
c288638a
Commit
c288638a
authored
Nov 30, 2020
by
o
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support for deleting resources
parent
7eb52b93
Pipeline
#4765
passed with stages
in 17 minutes and 8 seconds
Changes
6
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
51 additions
and
6 deletions
+51
-6
app/controllers/concerns/api_backend.rb
app/controllers/concerns/api_backend.rb
+2
-2
app/controllers/resources_controller.rb
app/controllers/resources_controller.rb
+16
-0
app/views/resources/create.html.erb
app/views/resources/create.html.erb
+2
-0
app/views/resources/show.html.erb
app/views/resources/show.html.erb
+29
-3
app/views/resources_admin/_resource_create.erb
app/views/resources_admin/_resource_create.erb
+1
-1
config/routes.rb
config/routes.rb
+1
-0
No files found.
app/controllers/concerns/api_backend.rb
View file @
c288638a
...
...
@@ -370,8 +370,8 @@ module ApiBackend
post
([
'resource'
,
'undelete'
],
{
uid:
uid
})
end
def
resource_delete
(
uid
)
post
([
'resource'
,
'delete'
],
{
uid:
uid
})
def
resource_delete
(
uid
,
pw
=
nil
)
post
([
'resource'
,
'delete'
],
{
uid:
uid
,
password:
pw
})
end
def
resource_add_owner
(
uid
,
user
)
...
...
app/controllers/resources_controller.rb
View file @
c288638a
...
...
@@ -51,4 +51,20 @@ class ResourcesController < ApplicationController
flash
[
:danger
]
=
e
.
api_msg
redirect_to
new_resource_path
end
def
update
uid
=
params
[
:uid
]
pw
=
params
[
:password
]
if
params
[
:delete
].
present?
@res
=
api
.
resource_delete
(
uid
,
pw
)
flash
[
:success
]
=
:success
end
redirect_to
resources_path
rescue
ApiError
=>
e
flash
[
:danger
]
=
e
.
api_msg
redirect_to
resources_path
end
end
app/views/resources/create.html.erb
View file @
c288638a
<h3>
<%=
t
(
:new_resource
)
%>
</h3>
<nav>
<div
class=
"nav nav-tabs"
id=
"nav-tab"
role=
"tablist"
>
<%
@resource_names
.
each
do
|
pane
|
%>
...
...
app/views/resources/show.html.erb
View file @
c288638a
<pre>
<%=
@resources
.
to_yaml
%>
</pre>
<h3>
<%=
t
(
:my_resources
)
%>
</h3>
<p>
<%
@resources
.
each
do
|
res
|
%>
<%
resource_ui_id
=
SecureRandom
.
hex
(
32
)
%>
<%=
form_tag
do
%>
<%=
hidden_field_tag
'uid'
,
res
%>
<%=
res
%>
<button
type=
"button"
class=
"btn btn-warning"
onclick=
"
style.display='none';
document.getElementById('delete_
<%=
resource_ui_id
%>
').style.display='inline';
"
>
<%=
t
:delete
%>
</button>
<div
id=
"delete_
<%=
resource_ui_id
%>
"
style=
"display:none"
>
<p>
<div
class=
"form-group"
>
<%=
label_tag
:password
,
t
(
:your_main_pw
)
%>
<%=
password_field_tag
'password'
%>
</div>
<%=
submit_tag
(
t
(
:delete
),
name:
"delete"
,
class:
"btn btn-danger"
)
%>
</p>
</div>
<%
end
%>
<hr
/>
<%
end
%>
</p>
app/views/resources_admin/_resource_create.erb
View file @
c288638a
...
...
@@ -3,7 +3,7 @@
<%
@resource_schema
.
each
do
|
n
,
v
|
%>
<div
class=
"form-group"
>
<%=
label_tag
n
%>
<%=
label_tag
'data_'
+
n
,
n
%>
<%=
case
v
when
'text'
text_field_tag
(
'data_'
+
n
,
""
,
class:
'form-control'
)
...
...
config/routes.rb
View file @
c288638a
...
...
@@ -66,6 +66,7 @@ Rails.application.routes.draw do
get
'/msg'
,
to:
'application#msg'
get
'/resources'
,
to:
'resources#show'
post
'/resources'
,
to:
'resources#update'
get
'/new_resource'
,
to:
'resources#create'
post
'/new_resource'
,
to:
'resources#do_create'
else
...
...
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