AngularJS- custom filter or directive? - angularjs

I have a site that will be displaying lots of number entry fields. The user will be entering the numbers, or using large plus & minus buttons to increment them.
These numbers will be things like age, annual income, percentages, or consumer prices.
I want to build a single, standard way of dealing with these numbers.
I explored the filters like {{priceOfCoffee | currency}}, which will work for those simple items, but when I get to the others, I have extra requirements.
For example, I want the annual income to have a $ prepended, group the 000s but have no decimal. I'll also want to restrict input to only numbers, etc.
I know I can do these with custom filters, or directives, but I'm just not sure whether it makes sense to create several custom filters, or a directive to which I can pass parameters.
Thoughts?
Thanks,
Scott

If you only care about formatting a single piece of text use a filter. If you want to reuse an entire block of content use a directive. It's difficult to be more specific with only a generic description of the application.
I had an application where I got medication information from the server which I needed to format, but I also wanted to use it in multiple places in the app. So I made a directive so I could reuse the entire block of content, but within that directive information about the dosage was formatted with filters.

Related

is there a standard way of inserting additional html into directive template for one off cases?

I have a directive w/ a template that will work in 90% of scenarios. However there are some scenarios where I'll need additional fields be added to the template. Is there a way to extend or modify an existing html template so that adding additional fields is a possibility without rebuilding 90% of an existing template?
I know that you can compose a new directive w/ a base directive. However this only serves to add functionality and content around the base directive and doesn't allow for the ability, from what I know, to insert additional html into or around the base template in a way that allows for the additional html to be recognized in the context of the base html.
In my case I have 5 standard input fields. However in some cases I need to insert additional input fields, not before or after the base 5 but literally intersperse them between the base inputs. Using bootstrap, I can apply an order to the various input fields and theoretically i can take the the additional inputs into account and supply orders accordingly. However, bootstrap cannot recognize the inputs as being part of the same row-cols ordering logic if the base content is separated into a containing div separating its content from that of any directive which composes off of it.
It seems like angularjs's directives are specifically designed to group base directive content into a single and separate container object. This is the error if you try and use the directives replace functionality w/o having a single template container: https://code.angularjs.org/1.4.7/docs/error/$compile/tplrt
Is this simply a short coming of angularjs's abilities for composition or is there some other piece to this puzzle that I'm missing?
Can't you simply do this on the front end with ... So that the input fields in question would only show up if your edge case is true. Save your condition variable in scope and based on that display/hide the fields. Unless I'm not understanding the question.

How to manage large amount content on one page in a clean user searchable way, filters

I've presented them all as a list in 3 columns (see here: http://focallocal.org/action/ ) but i need to double the amount there now and it is going to look terrible.
what we really need is filters to cross reference and organize them as the number will grow to over 100 soon. Any suggestions for managing and organizing the large amount of content?
It doesn't have to be on one page as long as i can put a short intro and photo to each page
I suggest making a separate post for each of your project descriptions with a custom post type called "project" or similar to group them all (and so it doesn't affect any ordinary blog posts.)
How to add a custom post type
Next, you need to "flush" the permalinks (Settings > Permalinks, click Save Changes.)
The Project posts can be split into categories or you can add tags (less formal) and each post can have a featured image.
If you called your post type "project", you will be able to view an index of all of them at http://example.com/project, which, taking the TwentyFourteen theme as an example, will use the archive.php file as a template (see the Template Hierarchy.)

Iframe content not able to save in module params Joomla

I am using Joomla3 with tinymce editor. I have created one module and adding one params in textarea
I am adding iframe code
in text area
but it's not saving. If i am save normal text string then it's saving
Please help me
I believe you need to add a filter to your xml code.
such as:
filter="RAW" or, probably more appropriately, filter="HTML"
This will keep Joomla from cleaning your code. There are a number of filters available to XML fields when creating modules. You can examine the code here: https://github.com/joomla/joomla-cms/blob/master/libraries/joomla/filter/input.php#L167 to see the exact list.
What user group is the account you are using a member of? Super Users and Administrator group types should have no filtering set by default but it sounds like you might need to edit those settings.
From the main menu:
System > Global Configuration > Text Filters (tab)
You will see all the available user groups for you website. The group your user belongs to should have a Filter Type of No Filtering. Another important note is its better to add the user account to a group with the permissions then to arbitrarily adding it to a group type typically reserved for registrants, guests or low-level editing.

Outputting Stripe plan name via plan-ID using AngularJS ng-model two-way data binding

I am outputting form inputs on the final page of a checkout field, titled "Review & checkout"... on this page I display the plan the customer picked and the personal info they provided so far.
I have no problem showing fields like Name or Email, as the value inputted is being shown, as Angular displays whatever was in the value="" field of the input.
To display the subscription plan that the customer picked, it's trickier.
The value field is already being utilized to tell stripe which plan the customer should be charged for.
How can I get around this problem?
I am able to display the stripe-id for the plan but it is not user-friendly. They are id's like trad-2-5, trad-2-6, trad-2-7... so what I want to do is display a custom title when trad-2-5 is selected, and so on...
Any help is greatly appreciated!!Thanks
There are a couple of ways you could do this.
The really silly answer is that you can just create a map of plan ids to human-readable descriptions in the Angular controller code, then display that. This might be enough for what you want, but it's also pretty hacky, and not a lot of fun to maintain.
The less silly answer depends on where these plan ids are coming from. If they are coming from an endpoint on your server, which gets them from Stripe's plans endpoint, then you could also pass along the display name of the plan from that endpoint. If the plan id's are hard coded somewhere, or whitelisted, then this may not make sense. However, that display name is what will appear on the customer's invoice, and credit card statement, so it'd be nice to make it match up with what they see on the checkout page.

Salesforce.com visualforce between 2 objects

In salesforce I need to create a visualforce page that includes the fields of 2 objects. The first object is the QUOTE object. The second objects is a custom object with several fields.
I want to create a visualforce page that shows the records of both QUOTE and the new object. Can I do this without creating a custom controller? If no any hints on the code for this new controller?
Can I do calculations between fields in a visualforce page?
Ideally I want this page to appear as soon as the QUOTE is set to ACCEPTED
1: You can't do this without a custom controller unfortunately, unless one object is related to the other and you're just happy displaying it as a related list on the parent object's page. For calculations you could use rollup summaries for some basic sums etc..
As for a custom controller, have a look at field sets for a super easy way to get fields into a VF page, you essentially configure groups of fields on your objects and then you can stick those groups onto a page with minimal markup.
2: For fields with complex calculations you'll want to do the sums in the controller and then expose the results through variables onto the page in the usual manner.
3: Not really possible without creating a custom edit page in the first place — you'd be better off having a button on the quote page to open up the Visualforce page, that page can simply display an error if the quote is not yet accepted. There are some other alternatives that might work though, like using a forumla field to generate a link to the page when the status is as you desire.
I'm happy to elaborate on any of this, but the fact that you're asking about number 2 would suggest to me that you don't have much experience developing on the platform (not a dig, just an observation), so unless you're comfortable coding in other environments you could find this quite tricky. That said, you're on stackoverflow so I'm thinking you probably know a little about coding at least!

Resources