Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
itminedu
synnefo
Commits
649fa61d
Commit
649fa61d
authored
Nov 04, 2013
by
Kostas Papadimitriou
Browse files
ui: Additional storage_attrs funcionality
allow custom model id resolver
parent
e956e8d4
Changes
1
Hide whitespace changes
Inline
Side-by-side
snf-cyclades-app/synnefo/ui/static/snf/js/models.js
View file @
649fa61d
...
...
@@ -135,6 +135,12 @@
var
store
,
key
,
attr_name
;
store
=
synnefo
.
storage
[
params
[
0
]];
key
=
params
[
1
];
attr_resolver
=
params
[
2
];
if
(
!
attr_resolver
)
{
attr_resolver
=
function
(
model
,
attr
)
{
return
model
.
get
(
attr
);
}
}
attr_name
=
attr
;
var
resolve_related_instance
=
function
(
storage
,
attr_name
,
val
)
{
...
...
@@ -165,17 +171,19 @@
self
.
trigger
(
"
change:
"
+
attr_name
,
obj
);
clearInterval
(
retry
);
}
},
1
0
);
},
50
0
);
}
}
var
self
=
this
;
this
.
bind
(
'
change:
'
+
attr
,
function
(
model
)
{
resolve_related_instance
.
call
(
model
,
store
,
key
,
attr_resolver
(
model
,
attr
));
},
this
);
this
.
bind
(
'
change:
'
+
attr
,
function
()
{
resolve_related_instance
.
call
(
this
,
store
,
key
,
this
.
get
(
attr
))
});
this
.
bind
(
'
add
'
,
function
()
{
resolve_related_instance
.
call
(
this
,
store
,
key
,
this
.
get
(
attr
))
});
this
.
bind
(
'
add
'
,
function
(
model
)
{
resolve_related_instance
.
call
(
model
,
store
,
key
,
attr_resolver
(
model
,
attr
));
},
this
);
resolve_related_instance
.
call
(
this
,
store
,
key
,
attr_resolver
(
this
,
attr
));
},
this
);
},
...
...
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