Changing activeadmin use of model name to another method in forms and show pages - activeadmin

ActiveAdmin seems to use #name as a default #to_s method to present in a few places, but this isn't the case with our data model.
I found adding to_label on the model fixes forms, thanks to formtastic, but haven't seen a way in the docs to do this for ActiveAdmin itself, e.g. in its show pages. Is there a configuration I didn't see, or do we need to override/reimplement all the stuff that uses #name?

You can change the name of the model in a translation file:
Create a file: config/locales/activerecord.en.yml
Instead of en you should use your own local in the file name
In the .yml file:
en:
activerecord:
models:
your_original_model_name: 'Your custom model name'
...

Related

Typo3 9 RTE CK_Editor 4 data-attribute in span removed after saving

I tried to save data-attribute inside a span tag. After saving it`s removed.
I tried the following configurations in my custom yaml file.
processing.allowAttributes:
-'span[data]'
processing.allowTags:
-span
editor.config.extraAllowedContent: "*(*)[data-*]"
Nothing helped.
Where is the problem?
To allow saving data attributes to db from RTE fields, you need to ensure that:
1) RTE (CKEditor) will not strip the attributes. This is configurable using extraAllowedContent. Below is an example how to allow id attributes additionally to the default rule which allows data attributes and classes.
editor:
config:
extraAllowedContent:
- "*(*)[data-*]"
- "*[id]"
If you only need to add data attributes, you don't need the configuration above and can relay on default configuration (from rte_ckeditor/Configuration/RTE/Editor/Base.yaml), as data attributes are allowed by default there.
2) then you need to configure PHP side of things - data transformation which happens before data is saved to db. See manual chapter: https://docs.typo3.org/m/typo3/reference-coreapi/master/en-us/ApiOverview/Rte/Transformations/Process.html#transformations-process
Below is an example (taken from RTE yaml preset) of allowing data-abc attribute in transformation (in addition to attributes which are allowed by default).
processing:
allowAttributes: [class, id, title, dir, lang, xml:lang, itemscope, itemtype, itemprop, data-abc]
So in your case you were missing proper allowAttributes configuration.

How to change the display field to use when use jdl?

When use jhipster entity generator by console a question like follow allows to change the display field on frontend:
When you display this relationship with AngularJS, which field from
'user' do you want to use? (id)
It is possible to make the same with jdl?
Edited
Ok, It appears that nobody has this problem, or maybe there aren't anybody in home?
So, I'm going to explain it. Let's suppose this scenario:
Create two (or more) entities with relationship with the console.
Choose a different field from id to manage the front-end.
Test the project (it works fine).
Export the model to jdl file
Import the jdl file, with no changes, in another new project.
Boom! The UI comes back to Id reference.
Is there any option to resolve it, or is this resolve in other tools like uml import? Future plans?
Resolved
Reading the documentation in detail, I've found a solution:
"Declare the field you want to use to display a relationship in AngularJS.
To do that you must add the field name between () after the injected field name."
Resolved
Reading the documentation in detail, I've found a solution:
"Declare the field you want to use to display a relationship in
AngularJS.
To do that you must add the field name between () after the injected
field name."

Loopback - Easiest way to extend a built-in model

I've been using Loopback to create an API. The documentation is generally really good but doesn't really answer my question about the following: how do I extend (not replace) a built in model?
The most promising piece of information came from this page - it specifies the way of basing a class from another class, via inheritance. This is useful but not ideal - I'd like to create relationships to custom models from the stock models, for example - "Role" should have many "Permission".
The page I mention also shows a Javascript file, located at common/models/<modelName>.js, where it states you can "extend" a model based on the properties and options you give it. The server never seems to hit the file... For example - I put a file in common/models/role.js with the following content:
var properties = {
exampleProperty: {type: String, required: true}
};
var user = loopback.Model.extend('Role', properties);
console.log('test');
First off, it doesn't seem to hit the file at all (no console.log output given). Second, obviously because of the first point, it doesn't extend the model with the properties I created.
Am I missing something obvious or is the documentation just plain wrong?
You should generate a new model via slc loopback:model named user. By default, the built in user is named User, which is why you can use lowercase user or even UserModel if you prefer. Then when you are prompted by the model generator for a base model, choose User. See https://github.com/strongloop/loopback-faq-user-management/blob/master/common/models/user.json#L3

Umbraco add custom Document Type

Is it possible to add a custom control to the Document Type? Suppose i couldn't create a multiselect or just a simple textfield control. How could i create a custom one and use that from the Document Type page in Umbraco?
If this is possible, then what steps need to be taken? Because i can add all sorts of config information in the Document Type controls that currently exist in there. Like, when i add a textfield i can gvie it a name, an alias and a validation message (and it has some others options).
Do i have to build the custom Document Type control in a specific way? And how is it saved to the database? How does Umbraco handle that?
Any information on this matter is more than welcome!
Since adding custom document types is native to Umbraco, and judging by the description in your question, I'm going to assume that you are talking about adding custom data types with user controls.
If so, check some of the following links on the subject, it's actually fairly simple:
Creating custom datatypes using the umbraco usercontrol wrapper (I personally used this one)
Custom DataTypes in Umbraco
Creating a custom datatype using the usercontrol wrapper (Video tutorial)

Renaming Core Data class

I have an application that uses CoreData.
I previously had a class named Marker which was linked to the Marker entity in Core Data.
I renamed the Marker class to CoreDataMarker. So I created a new .xcdatamodel file with the new class name for the entity. Then I created a .xcmappingmodel and selected the old and the new .xcdatamodel files and it seemed to 'auto-setup' fine.
However, when I run my application it complains with: "Can't merge models with two different entities named 'Marker'". I understand that this happens, but I have no idea how to solve it.
Do you know how?
Thanks in advance!
You don't need a new xcdatamodel. Change the in the "Class" field in the entity description for your Marker entity to CoreDataMarker. That's all that's needed. The implementing class information does not require a schema migration.
And make sure ONLY the current version of the data model (latest xcdatamodel file) is included in target and mapping model file. It looks like putting other model files are being done automatically based on information from xcmappingmodel file.
It is unintuitive but this was what worked for me.

Resources