Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gutyán Gábor
/
circlestack
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
97277697
authored
Sep 11, 2013
by
Kálmán Viktor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
network: create record button from domain edit
parent
44798159
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
57 additions
and
39 deletions
+57
-39
circle/network/static/js/network.js
+7
-0
circle/network/static/js/record.js
+40
-35
circle/network/templates/network/domain-edit.html
+4
-4
circle/network/views.py
+6
-0
No files found.
circle/network/static/js/network.js
View file @
97277697
...
@@ -20,3 +20,10 @@ function getCookie(name) {
...
@@ -20,3 +20,10 @@ function getCookie(name) {
}
}
return
cookieValue
;
return
cookieValue
;
}
}
function
getURLParameter
(
name
)
{
return
decodeURI
(
(
RegExp
(
name
+
'='
+
'(.+?)(&|$)'
).
exec
(
location
.
search
)
||
[,
null
])[
1
]
);
}
circle/network/static/js/record.js
View file @
97277697
...
@@ -255,6 +255,41 @@ function resetName() {
...
@@ -255,6 +255,41 @@ function resetName() {
}
}
/*
* error creating function
*
* first it removes the current error message, then it iterates through
* all the given messages
*/
function
appendMessage
(
type
,
messages
,
id
)
{
$
(
'#js_error'
).
remove
();
resetErrors
();
message
=
'<div id="js_error" style="display: none;" class="alert alert-danger"><ul>'
for
(
var
i
=
0
;
i
<
messages
.
length
;
i
++
)
{
message
+=
"<li>"
+
messages
[
i
].
message
+
"</li>"
;
if
(
messages
[
i
].
id
)
{
$
(
'#id_'
+
messages
[
i
].
id
).
closest
(
'div[class="form-group"]'
).
addClass
(
"has-error"
);
}
}
message
+=
'</ul></div>'
;
$
(
'form'
).
before
(
message
);
$
(
'html, body'
).
animate
({
scrollTop
:
0
},
'slow'
,
function
()
{
$
(
'#js_error'
).
fadeIn
();
});
}
// remove error class from forms if we click on them
// it also removes the help-inline span that shouldn't really appear
$
(
'* [id^="id_"]'
).
focus
(
function
()
{
id
=
"#div_"
+
$
(
this
).
prop
(
'id'
);
if
(
$
(
id
).
hasClass
(
'has-error'
))
{
$
(
id
).
removeClass
(
'has-error'
);
$
(
'span[id="error_1_'
+
$
(
this
).
attr
(
'id'
)
+
'"]'
).
remove
();
}
});
// on page load
// on page load
// if we are upadting
// if we are upadting
// - set the name and address
// - set the name and address
...
@@ -268,6 +303,10 @@ $(function() {
...
@@ -268,6 +303,10 @@ $(function() {
}
}
// else we are creaing a new
// else we are creaing a new
else
{
else
{
domain
=
getURLParameter
(
'domain'
);
if
(
domain
!=
'null'
&&
domain
.
length
>
0
)
{
new_record
=
false
;
}
else
{
new_record
=
true
;
new_record
=
true
;
// hide all input containers
// hide all input containers
$
(
'div[id^="div_id_"]'
).
hide
();
$
(
'div[id^="div_id_"]'
).
hide
();
...
@@ -284,6 +323,7 @@ $(function() {
...
@@ -284,6 +323,7 @@ $(function() {
);
);
$
(
'#div_id_type'
).
fadeIn
();
$
(
'#div_id_type'
).
fadeIn
();
}
}
}
});
});
// if the user choose a type
// if the user choose a type
...
@@ -303,38 +343,3 @@ function type_next() {
...
@@ -303,38 +343,3 @@ function type_next() {
}
}
return
false
;
return
false
;
}
}
/*
* error creating function
*
* first it removes the current error message, then it iterates through
* all the given messages
*/
function
appendMessage
(
type
,
messages
,
id
)
{
$
(
'#js_error'
).
remove
();
resetErrors
();
message
=
'<div id="js_error" style="display: none;" class="alert alert-danger"><ul>'
for
(
var
i
=
0
;
i
<
messages
.
length
;
i
++
)
{
message
+=
"<li>"
+
messages
[
i
].
message
+
"</li>"
;
if
(
messages
[
i
].
id
)
{
$
(
'#id_'
+
messages
[
i
].
id
).
closest
(
'div[class="form-group"]'
).
addClass
(
"has-error"
);
}
}
message
+=
'</ul></div>'
;
$
(
'form'
).
before
(
message
);
$
(
'html, body'
).
animate
({
scrollTop
:
0
},
'slow'
,
function
()
{
$
(
'#js_error'
).
fadeIn
();
});
}
// remove error class from forms if we click on them
// it also removes the help-inline span that shouldn't really appear
$
(
'* [id^="id_"]'
).
focus
(
function
()
{
id
=
"#div_"
+
$
(
this
).
prop
(
'id'
);
if
(
$
(
id
).
hasClass
(
'has-error'
))
{
$
(
id
).
removeClass
(
'has-error'
);
$
(
'span[id="error_1_'
+
$
(
this
).
attr
(
'id'
)
+
'"]'
).
remove
();
}
});
circle/network/templates/network/domain-edit.html
View file @
97277697
...
@@ -16,10 +16,10 @@
...
@@ -16,10 +16,10 @@
{% crispy form %}
{% crispy form %}
</div>
</div>
<div
class=
"col-sm-6 col-sm-offset-1"
>
<div
class=
"col-sm-6 col-sm-offset-1"
>
<
h3
>
<
div
class=
"page-header"
>
{% trans "List of this domain's records" %}
<a
href=
"{% url "
network
.
record_create
"
%}?
domain=
{{
domain_pk
}}"
class=
"btn btn-success pull-right btn-xs"
><i
class=
"icon-plus-sign"
></i>
{% trans "Add new record" %}
</a>
</h3>
<h3>
{% trans "List of this domain's records" %}
</h3>
<
hr
/
>
<
/div
>
<div
class=
"table-responsive"
>
<div
class=
"table-responsive"
>
{% render_table record_list %}
{% render_table record_list %}
</div>
</div>
...
...
circle/network/views.py
View file @
97277697
...
@@ -459,6 +459,12 @@ class RecordCreate(CreateView, SuccessMessageMixin):
...
@@ -459,6 +459,12 @@ class RecordCreate(CreateView, SuccessMessageMixin):
# TODO fqdn
# TODO fqdn
success_message
=
_
(
u'Successfully created record!'
)
success_message
=
_
(
u'Successfully created record!'
)
def
get_initial
(
self
):
return
{
# 'owner': 1,
'domain'
:
self
.
request
.
GET
.
get
(
'domain'
),
}
class
RecordDelete
(
DeleteView
):
class
RecordDelete
(
DeleteView
):
model
=
Record
model
=
Record
...
...
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