AdminJS how to make field mandatory - adminjs

I have been looking for a long time and I have no idea how to do it, do you have a simple solution to make a field mandatory in the action/new or edit pages ? Thanks

You need to add isRequired:true to the field. See the document here
....
resource: YourResource,
options: {
properties: {
YourField : {isRequired: true}
}
}
....

Related

Cypress Version12: alias-ing variable for later use are overwritten when changing the field

In the migration to cypress 12 it says that the aliases are adapted according to the dom, I know. But I did not expect this:
In my case, I have a field with a first value. I put this value into an Alias for later use. Into the same field I write now something else. Later, I want to restore the field again to the previous value (stored as alias). But in this alias is the new value and not the previous one:
This is how I store the fist value:
function aliasAliasNameValue() {
cy.get(`div[data-textfield="editField"] input`)
.invoke('attr', 'value').as('ALIASNAME')
.then((attVal) => {
cy.log(attVal as string);
});
}
This is how I get the first value:
function restoreAliasField() {
cy.get('#ALIASNAME').then((aliasN) => {
cy.get(`div[data-textfield="editField"] input`)
.clear()
.type(aliasN as unknown as string);
});
}
Here is a description of the test:
it('Change field and restore it.', () => {
// do something....
...
aliasAliasNameValue();
...
// change the field save and come back
restoreAliasField(); // but it is not restored: it writes the new value!!
...
});
How can I get the first value back?
I think this line is not working .type(aliasN as unknown as string).
It looks like you are trying to define the type, but you should just try with .type(aliasN) and see it that improves things for you.
As of version 12.4.0 you can use it again. Although it is necessary to add an additional parameter:
.as('ALIASNAME', { type: 'static' }
type: 'query' would update the variable...

Sort allContentAsset by tag in Gatsby is it possible?

I try for few days to sort my Asset media by the tag than I added on each Asset in Contentful, but I failed on each try...
See my previous question about that sort content by tag in Gatsby with Conteful API
So I'm back to a simplest configuration, just sort the raw asset !
What is good sentence to write sort and filter to catch only the media with tag artWork?
Because I try to understand the gatsby example for that... and it's not easy
https://www.gatsbyjs.com/plugins/gatsby-source-contentful/#contentful-tags
{
allContentfulAsset() {
edges {
node {
title
}
}
}
}
Sort allContentAsset by tag in Gatsby is it possible?
Absolutely. You only need to apply one of the multiple GraphQL filters in Gatsby's implementation. For example:
{
allContentfulAsset(
filter: {
metadata: { tags: { in: ["art work", "vies paralleles"] } }
}
) {
edges {
node {
title
}
}
}
}
The previous snippet will get allContentfulAsset where those tags contain "art work" and "vies paralleles". Assuming the interpolation between assets and tags exists (i.e: tags is selectable a field in assets). If this interpolation is not present or it's not properly done, allContentfulAsset will never have tags to filter so your query will break.
Keep in mind that to use tags, you need to set the enableTags flag as true (set as default as false) by:
{
resolve: `gatsby-source-contentful`,
options: {
spaceId: process.env.CONTENTFUL_SPACE_ID,
accessToken: process.env.CONTENTFUL_ACCESS_TOKEN,
enableTags: true,
},
},
According to this pull-request the enableTags feature was fixed in the cutting-edge release(5 days ago) so try to upgrade your plugin dependency.
It should be fixed in (inferred in this GitHub thread):
gatsby-source-contentful#7.5.0-next.0
Please provide feedback on previous questions/answers rather than keep opening new ones. Even delete the previous ones or provide feedback about what you've tried...

Simple GraphQL Query using the Graph

So I'm trying to learn graphql I've been playing around with the ENS subgraph on the graph
For now I'm just trying to do some simple filtering: I would like to be able to filter by the property name:
{
domains(name:"cocacola.eth") {
id
name
labelName
labelhash
}
}
However this doesn't seem to work
I don't know if I was looking at an old version of graphql when I tried making that query but when following another online I found I can specify using the where parameter:
{
domains(where:{name: "cocacola.eth"}) {
id
name
labelName
labelhash
}
}

Ember-validation how to implement lazy validation

I am using ember-cli:2.5.0 and ember-validations:v2.0.0-alpha.5
In my ember-component i have a validation which is running automatically for each change in a attribute but i want to run this validation only if i call "validate()" method in technical term call validation lazily.
Please find the below code samples,
import Ember from 'ember';
import EmberValidations, { validator } from 'ember-validations';
export default Ember.Component.extend(EmberValidations, {
didReceiveAttrs() {
this.set('newBook', this._bookModel().create());
},
_bookModel(data = {}) {
return Ember.Object.extend(EmberValidations, {
bookVersion: null,
isEditable: false,
validationActive: false,
validations: {
bookVersion: {
inline: validator(function() {
if(this.validationActive){ //Here this.validationActive always return undefined
var version = this.model.get('bookVersion') || "",
message = [];
if (Ember.isEmpty(bookVersion)) {
message.push("Book Version is mandatory!!!");
}
if (message.length > 0) {
return message.join(',');
}
}
})
}
}
}, data);
}
});
actions: {
this.get('newBook').set("validationActive",true);
this.get('newBook').validate().then(() => {
//Do the action
}
}
I want the above validation to run only calling "this.get('newBook').validate()". I am entirely new to ember so down-voter please put your comments before down-voting for others kindly let me know for any more code samples.
Your help should be appreciable.
The addon you are using for validations ("ember-validations") is a very popular one and its documentation is pretty well when compared to others. If you look at the documentation there is a part named "Conditional Validators" in documentation. You can use a boolean property to control when the validation is to be performed.
You can see an illustration of what I mean in the following twiddle. I have created a simple validation within the application controller for user's name. The name field must have a length of at least 5 and the validation is to be performed only if the condition validationActive is true. Initially; the condition is false; which means validator did not work and isValid property of Controller (which is inherited from EmberValidations Mixin) is true. If you toggle the property with the button provided; the validation will run (since the condition is now set to true; hence validation is triggered) and isValid will return to false. If you change the value; the validation result will change appropriately with respect to the value of user's name. If you toggle the condition once again to set it to false; then isValid will become true no matter what the valie of user's name is.
I hope this gives you an insight about how to control when your validations should work.
Here is what you should do after your edit: The field is undefined because you are trying to reach component's own validationActive field within inline validator. Please get validationActive as follows this.model.get('validationActive') and give a try. It should work.

Validation rule in Oracle Sales Cloud

Sorry if this is the wrong place to ask, but I'm writing this validation rule in Oracle Sales Cloud 11 on the account object (field : Address Line 1), and it always returns false even if true, I don't get it. I've tried several formulations, but the issue remains, thanks a lot for your help.
if (PrimaryAddressLine1 == null) {
return false
}
else {
return true
}
Instead of putting the validation at object level, can you place the required/mandatory requirement by configuring in Manage Address Formats and handle it there. Making Address Line 1 required at this Level will make it required across objects where OOTB Address Section is used.
You can try the following code:
if (!PrimaryAddressLine1) {
return false } else {
return true }

Resources