Skip to content

WIP: smRadioGroup and smRadioButton directives #10

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 3 commits into from
May 14, 2015

Conversation

m0t0r
Copy link
Contributor

@m0t0r m0t0r commented Feb 23, 2015

Status: Work in progress
Based on #5

@m0t0r
Copy link
Contributor Author

m0t0r commented Mar 4, 2015

@caitp how does it look like so far ?

'<sm-radio-button value="1">One</sm-radio-button>',
'<sm-radio-button value="2">Two</sm-radio-button>',
'<sm-radio-button value="3">Three</sm-radio-button>',
'</sm-radio-group>'].join('')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: should probably just make a helper function that does this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where that helper function should be placed ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@caitp, can you make a refresh in here please. What sort of helper function did you mean ? and also my initial question is still needs an answer :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

something like

function createRadioGroup(model, valuesAndLabels) {
  var template = '<sm-radio-group ng-model="' + model + '">' +
                 Object.getOwnPropertyNames(valuesAndLabels).map(function(value) {
                   var label = valuesAndLabels[value];
                   return '<sm-radio-button value="' + value + '">' + label + '</sm-radio-button>';
                 }).join("") + '</sm-radio-group>';
  element = $compile(template)($scope);
  // and whatever other setup you want to do
}

var kBaseKeys = Object.freeze({
  1: "One",
  2: "Two",
  3: "Three"
});

createRadioGroup("value",  kBaseKeys);

or something like that --- but it's your call man, it can just be a bit nicer to write tests without having to do lots of string concatenation and stuff

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks nice, thank you.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually, Object.keys is probably a better option, so you avoid engine stuff creeping in... might be better to use arrays to keep the order. anyway, do whatever works for you

@caitp
Copy link
Member

caitp commented Mar 4, 2015

the implementation basically looks okay to me, room for a few improvements, but mostly just nits

@caitp
Copy link
Member

caitp commented Apr 14, 2015

you can certainly merge this whenever you like, if you want to, adding helpers to the test suite to make it a bit easier to write tests is something you can do later (or not), if you like.

LGTM

@m0t0r
Copy link
Contributor Author

m0t0r commented Apr 14, 2015

I haven't added any accessibility stuff, that matters as I understood from the first directives, will add that part also and then good to go for merge 👍

@caitp
Copy link
Member

caitp commented Apr 14, 2015

+1

@m0t0r
Copy link
Contributor Author

m0t0r commented May 14, 2015

@caitp Can we land this and then improve the accessibility stuff ? I am finishing one project and hope to get more free time.

@caitp
Copy link
Member

caitp commented May 14, 2015

yes, lgtm, merge at will =)

m0t0r added a commit that referenced this pull request May 14, 2015
…utton

WIP: smRadioGroup and  smRadioButton directives
@m0t0r m0t0r merged commit d1b96d9 into master May 14, 2015
@m0t0r m0t0r deleted the semantic-ui-elements-radio-button branch May 14, 2015 21:20
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants