made view component out of register view

This commit is contained in:
Torsten Ruger 2015-07-31 11:42:26 +03:00
parent 69e51a1037
commit 5bd6b3517d
4 changed files with 53 additions and 18 deletions

View File

@ -0,0 +1,26 @@
module Main
class RegistersController < Volt::ModelController
def initialize app , context
super(app , context)
self.model = []
init_registers attrs.interpreter
end
def init_registers interpreter
interpreter.registers.each do |reg , val|
r = RegisterModel.new( :name => reg , :value => val)
self.model << r
interpreter.register_event(:register_changed, r)
interpreter.register_event(:object_changed, r)
r.register_changed( reg , nil , interpreter.registers[reg])
end
end
def marker var
return "W" if var.is_a? String
var.class.name.split("::").last[0]
end
end
end

View File

@ -12,7 +12,6 @@
</div>
<div class="file-view">
Future Source code view
</div>
<div class="source-view">
@ -50,20 +49,4 @@
<span> {{page._interpreter._stdout}} </span>
</div>
<div class="registers-view">
{{ page._registers.each do |reg| }}
<div class="register-view">
<div>
{{ reg.name }}
</div>
<div>
{{ reg.value }}
</div>
{{ reg.fields.each do |attribute| }}
<div class="col-md-12">
{{marker(attribute)}} {{attribute.object_id}}
</div>
{{end}}
</div>
{{end}}
</div>
<:registers interpreter="{{ @interpreter }}"/>

View File

@ -0,0 +1,21 @@
<:Title>
registers index
<:Body>
<div class="registers-view">
{{ model.each do |reg| }}
<div class="register-view">
<div>
{{ reg.name }}
</div>
<div>
{{ reg.value }}
</div>
{{ reg.fields.each do |attribute| }}
<div class="col-md-12">
{{marker(attribute)}} {{attribute.object_id}}
</div>
{{end}}
</div>
{{end}}
</div>

View File

@ -0,0 +1,5 @@
require 'spec_helper'
describe '', type: :feature do
# Specs here
end