Fixed progressbar
This commit is contained in:
@@ -16,20 +16,28 @@ create
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
progress_value: INTEGER
|
||||
control: detachable WSF_PROGRESS_CONTROL
|
||||
|
||||
make
|
||||
make ()
|
||||
do
|
||||
progress_value := 0
|
||||
end
|
||||
|
||||
feature -- Implementation
|
||||
|
||||
set_control (c: WSF_PROGRESS_CONTROL)
|
||||
do
|
||||
control := c
|
||||
end
|
||||
|
||||
progress: INTEGER
|
||||
do
|
||||
Result := progress_value
|
||||
if progress_value < 100 then
|
||||
progress_value := progress_value + 1
|
||||
if attached control as c then
|
||||
Result := c.progress
|
||||
if c.progress < 100 then
|
||||
Result := Result + 1
|
||||
end
|
||||
else
|
||||
Result := 0
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ feature
|
||||
n4_container: WSF_FORM_ELEMENT_CONTROL [STRING]
|
||||
n5_container: WSF_FORM_ELEMENT_CONTROL [STRING]
|
||||
cats_container: WSF_FORM_ELEMENT_CONTROL [LIST [STRING]]
|
||||
source: INCREASING_PROGRESSSOURCE
|
||||
do
|
||||
Precursor
|
||||
create form.make_form_control ("panel")
|
||||
@@ -75,7 +76,9 @@ feature
|
||||
|
||||
--Progress bar
|
||||
container.add_control (create {WSF_BASIC_CONTROL}.make_with_body("h4","","Number1/Number2"))
|
||||
create progress.make_progress_with_source ("progress1", create {INCREASING_PROGRESSSOURCE}.make)
|
||||
create source.make
|
||||
create progress.make_progress_with_source ("progress1", source)
|
||||
source.set_control (progress)
|
||||
container.add_control (progress)
|
||||
end
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ trigger_callback = (control_name,event,event_parameter)->
|
||||
for name,state of new_states
|
||||
controls[name]?.update(state)
|
||||
return
|
||||
|
||||
class WSF_VALIDATOR
|
||||
constructor: (@parent_control, @settings)->
|
||||
@error = @settings.error
|
||||
@@ -256,13 +257,14 @@ class WSF_PROGRESS_CONTROL extends WSF_CONTROL
|
||||
|
||||
attach_events:() ->
|
||||
self = @
|
||||
setInterval(@fetch, 1000)
|
||||
runfetch= ()->
|
||||
self.fetch()
|
||||
setInterval(runfetch, 100)
|
||||
|
||||
fetch: ()->
|
||||
trigger_callback(@control_name, 'progress_fetch')
|
||||
|
||||
update: (state)->
|
||||
alert('update')
|
||||
if state.progress?
|
||||
window.states[@control_name]['progress'] = state.progress
|
||||
@$el.children('.progress-bar').attr('aria-valuenow', state.progress).width(state.progress + '%')
|
||||
|
||||
@@ -478,9 +478,12 @@
|
||||
}
|
||||
|
||||
WSF_PROGRESS_CONTROL.prototype.attach_events = function() {
|
||||
var self;
|
||||
var runfetch, self;
|
||||
self = this;
|
||||
return setInterval(this.fetch, 1000);
|
||||
runfetch = function() {
|
||||
return self.fetch();
|
||||
};
|
||||
return setInterval(runfetch, 100);
|
||||
};
|
||||
|
||||
WSF_PROGRESS_CONTROL.prototype.fetch = function() {
|
||||
@@ -488,7 +491,6 @@
|
||||
};
|
||||
|
||||
WSF_PROGRESS_CONTROL.prototype.update = function(state) {
|
||||
alert('update');
|
||||
if (state.progress != null) {
|
||||
window.states[this.control_name]['progress'] = state.progress;
|
||||
return this.$el.children('.progress-bar').attr('aria-valuenow', state.progress).width(state.progress + '%');
|
||||
|
||||
@@ -33,6 +33,9 @@ feature -- State handling
|
||||
|
||||
set_state (new_state: JSON_OBJECT)
|
||||
do
|
||||
if attached {JSON_NUMBER} new_state.item (create {JSON_STRING}.make_json ("progress")) as new_progress then
|
||||
progress := new_progress.item.to_integer
|
||||
end
|
||||
end
|
||||
|
||||
state: JSON_OBJECT
|
||||
|
||||
Reference in New Issue
Block a user