Skip to content

Commit bbc585d

Browse files
author
p01
committed
Tidied the show_resource* methods. Passing the data along and handling String IDs.
1 parent 6a38db7 commit bbc585d

File tree

1 file changed

+16
-27
lines changed

1 file changed

+16
-27
lines changed

src/resource-manager/resource_detail_view.js

Lines changed: 16 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -134,52 +134,41 @@ cls.ResourceDetailView = function(id, name, container_class, html, default_handl
134134
}
135135
};
136136

137-
this._show_resource = function(resource)
137+
this._show_resource = function(resource, data)
138138
{
139139
if (!resource || !resource.data)
140140
return false;
141141

142+
this.data = data;
142143
this.resource = resource;
143-
this._service.highlight_resource(resource.id);
144+
this._service.highlight_resource(resource.uid);
144145
this.update();
145146

146147
return true;
147148
};
148149

149-
this._show_resource_by_instance = function(resource)
150+
this._show_resource_by_instance = function(resource, data)
150151
{
151-
if (!this._show_resource(resource))
152-
this._show_resource_by_url(resource.url);
152+
if (!this._show_resource(resource, data))
153+
this._show_resource_by_key(resource.uid, data);
153154
};
154-
155-
this._show_resource_by_id = function(id)
155+
this._show_resource_by_key = function(key, data)
156156
{
157-
var resource = this._service.get_resource(id);
158-
159-
this._show_resource_by_instance(resource);
160-
};
157+
var service = this._service;
158+
var resource = service.get_resource(key) || service.get_resource_by_url(key);
161159

162-
this._show_resource_by_url = function(url)
163-
{
164-
var resource = this._service.get_resource_for_url(url);
160+
var url = resource?resource.url:key;
165161

166-
if (!this._show_resource(resource))
167-
this._service.request_resource(url, this.show_resource.bind(this), this.data);
162+
if (!this._show_resource(resource, data))
163+
service.request_resource_data(url, this.show_resource.bind(this), data, resource);
168164
};
169165

170-
this.show_resource = function(resource, data)
166+
this.show_resource = function(key, data)
171167
{
172-
this.data = data;
173-
this.resource = resource;
174-
175-
if (resource instanceof cls.ResourceInfo)
176-
this._show_resource_by_instance(resource);
177-
else if (resource == Number(resource))
178-
this._show_resource_by_id(resource);
179-
else if (resource == String(resource))
180-
this._show_resource_by_url(resource);
168+
if (key instanceof cls.ResourceInfo)
169+
this._show_resource_by_instance(key, data);
181170
else
182-
this.update();
171+
this._show_resource_by_key(key, data);
183172

184173
window.UI.instance.show_view( this.id );
185174
};

0 commit comments

Comments
 (0)