Skip to content

Commit

Permalink
Use proper fields based on type
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Moore authored and Brian Moore committed Mar 23, 2011
1 parent 809c2f6 commit ba92261
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 36 deletions.
17 changes: 11 additions & 6 deletions SalesForce-Sencha/app/Scontact/scontact_controller.rb
Expand Up @@ -25,11 +25,15 @@ def json
@contacts.each do |contact|
contact.vars.each do |k,v|
key = k.to_s.strip
if meta['datafields'][key] && meta['datafields'][key]["type"] == "reference"
begin
model = Object.const_get("S#{Scontact.metadata['datafields'][key]["referenceTo"][0].downcase}".to_sym)
contact.vars[k] = model.find(v).name
rescue Exception => e
if meta['datafields'][key]
if meta['datafields'][key]["type"] == "reference"
begin
model = Object.const_get("S#{Scontact.metadata['datafields'][key]["referenceTo"][0].downcase}".to_sym)
contact.vars[k] = model.find(v).name
rescue Exception => e
end
elsif meta['datafields'][key]["type"] == "boolean"
contact.vars[k].downcase!
end
end
end
Expand All @@ -39,7 +43,8 @@ def json


all = { :contacts => temp }
render :string => ::JSON.generate(all)
json_string = ::JSON.generate(all)
render :string => json_string

end

Expand Down
@@ -1,7 +1,10 @@

{
xtype: 'textfield',
xtype: '<%= @doc_def["xtype"] %>',
name : '<%= @doc_def["name"].gsub(/'/,"\\'") %>',
<%if @doc_def["options"]%>
options: <%= @doc_def["options"] %>,
<%end%>
label: '<%= @doc_def["label"].gsub(/'/,"\\'") %>',
useClearIcon: false
},
7 changes: 0 additions & 7 deletions SalesForce-Sencha/app/templates/sfsenchahidden.erb

This file was deleted.

11 changes: 0 additions & 11 deletions SalesForce-Sencha/app/templates/sfsenchareadonlytext.erb
Expand Up @@ -5,17 +5,6 @@
name : '<%= @doc_def["name"].gsub(/'/,"\\'") %>',
label: '<%= @doc_def["label"].gsub(/'/,"\\'") %>',
link_to: '<%= @doc_def["linkto"] %>',
listeners: {
focus: function() {
if(this.value && this.value != "") {
current = global.nav_stack[global.nav_stack.length - 1];
obj_id = get_id_for_field(current['model'],current['id'],this.name);
global.nav_stack.push({'id':obj_id,'model':this.link_to});
navigate();
}
this.blur();
}
},
useClearIcon: false,
renderTpl: [
'<tpl if="label">',
Expand Down
2 changes: 1 addition & 1 deletion SalesForce-Sencha/public/app/contact.js
Expand Up @@ -60,7 +60,7 @@ contact.SingleStore = new Ext.data.JsonStore({
fn: function(store,array,success) {
contact.DetailForm.user = store.data.items[0];
contact.FormPanel.loadModel(contact.DetailForm.user);
contact.FormPanel.doLayout();
contact.FormPanel.doComponentLayout();
contact.Page.show();
contact.Page.setActiveItem(1,'fade');
}
Expand Down
2 changes: 1 addition & 1 deletion SalesForce-Sencha/public/css/sencha.css
Expand Up @@ -19,7 +19,7 @@ body, html {
font-weight: bold;
}

.x-form-field-container input {
.x-form-field-container input, .x-form-field-container textarea {
font-size: 13px;
}

Expand Down
12 changes: 9 additions & 3 deletions SalesForce-Sencha/public/sencha/sencha-touch-debug.js
Expand Up @@ -25722,7 +25722,7 @@ Ext.DatePicker = Ext.extend(Ext.Picker, {
setValue: function(value, animated) {
if (!Ext.isDate(value) && !Ext.isObject(value)) {
value = null;
}
}

if (Ext.isDate(value)) {
this.value = {
Expand Down Expand Up @@ -28540,8 +28540,14 @@ Ext.form.DatePicker = Ext.extend(Ext.form.Field, {
this.value = (value != null) ? this.datePicker.getValue() : null;
} else {
if (!Ext.isDate(value) && !Ext.isObject(value)) {
value = null;
}
//RHO
if(value != "") {
value = new Date(value);
} else {
value = null
}
//RHO
}

if (Ext.isObject(value)) {
this.value = new Date(value.year, value.month-1, value.day);
Expand Down
6 changes: 4 additions & 2 deletions SalesForce-rhosync/sources/saccount.rb
Expand Up @@ -62,14 +62,16 @@ def metadata
data[key] = f

field = {}
type = "sfsenchafield"
type = "sfsenchagenericfield"
xtype = "textfield"
if f["type"] == "reference"
type = 'sfsenchalinkfield'
f["label"].gsub!(/ ID/,"")
elsif f["type"] == "id"
type = 'sfsenchahidden'
xtype = 'hiddenfield'
end
field = {
:xtype => xtype,
:label => f["label"],
:name => "#{key}",
:type => type,
Expand Down
33 changes: 29 additions & 4 deletions SalesForce-rhosync/sources/scontact.rb
Expand Up @@ -62,25 +62,50 @@ def metadata
data[key] = f

field = {}
type = "sfsenchafield"
xtype = "textfield"
type = "sfsenchagenericfield"
selectoptions = []

if f["type"] == "reference"
type = 'sfsenchalinkfield'
f["label"].gsub!(/ ID/,"")
elsif f["type"] == "id"
type = 'sfsenchahidden'
end
xtype = 'hiddenfield'
elsif f["type"] == "picklist"
xtype = 'selectfield'
f["picklistValues"].each do |v|
option = {}
option[:text] = v["label"]
option[:value] = v["value"]
selectoptions << option
end
elsif f["type"] == "boolean"
#sencha toggle broken, textfield for now
xtype = 'textfield'
elsif f["type"] == "textarea"
xtype = 'textareafield'
elsif f["type"] == "email"
xtype = 'emailfield'
elsif f["type"] == "date"
xtype = 'datepickerfield'
end


unless f["updateable"]
if not f["updateable"] and xtype == 'textfield'
type = 'sfsenchareadonlytext'
end

field = {
:xtype => xtype,
:label => f["label"],
:name => "#{key}",
:type => type,
:fieldtype => f["type"],
:linkto => f["referenceTo"][0]
}

field[:options] = selectoptions.to_json if xtype == 'selectfield'

show << field
end

Expand Down

0 comments on commit ba92261

Please sign in to comment.