Git Product home page Git Product logo

Comments (5)

tomglenn avatar tomglenn commented on July 17, 2024

I've added in the option for a property to be required now. After implementing it, I looked through the code and found some references to "mandatory" validation - but I can't see where this is used at all or how one would go about setting a property up to be mandatory.

Was this a feature that was never fully implemented or have I just reinvented the wheel?

For reference (and anyone interested in implementing it too) I have added a Required checkbox to the parameterconfig.prevalues.html file binding to property.value.required. And then in the parameterconfig.controller.js inside the property loop within $scope.isValid i've added:

if (property.$editor.required && property.value == null) { isValid = false; property.error = "This field is required"; return; } else { property.error = null; }

I then output this below each property in parameterconfig.html:
<div ng-if="property.error">{{property.error}}</div>

I haven't created this as a pull request because I'm still unsure as to whether this functionality is new and perhaps I've just not figured out how to activate it?

from leblender.

soreng avatar soreng commented on July 17, 2024

@tomeglenn a PR would be grealy appreciated

We have talked about this a bit, but not really found a good solution yet

from leblender.

jacklawry avatar jacklawry commented on July 17, 2024

@tomeglenn Can you please provide me with some more details on exactly what you changed to do this? I have tried but it just errors or are there different changes to make it work in the latest version of LeBlender & Umbraco?

from leblender.

tomglenn avatar tomglenn commented on July 17, 2024

Hi @jacklawry ,

Apologies for the delayed response. I never saw @soreng's request to make a PR, apologies.

I don't have a fork of LeBlender setup on my machine but I do have the commit log from when I implemented the functionality so I will explain it below.

App_Plugins/LeBlender/editors/leblendereditor/dialogs/parameterconfig.controller.js

Find the following if statement

if (!property.$valid)
	...
}

Directly after that if statement closes, add a new one containing the following.

if (property.$editor.required && property.value == null) {
	isValid = false;
	property.error = "This field is required";
	return;
} else {
	property.error = null;
}

App_Plugins/LeBlender/editors/leblendereditor/dialogs/parameterconfig.html
Find this line:

<blender-editor-wrapper property="property" item="item"></blender-editor-wrapper>

Directly after it add this line:

<div ng-if="property.error">{{property.error}}</div>

App_Plugins/LeBlender/editors/leblendereditor/dialogs/parameterconfig.prevalues.html
Find this section:

<umb-control-group label="Description" description="">
	...
</umb-control-group>

Directly after that, add this:

<umb-control-group label="Required" description="">
	<div style="text-align: left">
		<input type="checkbox" ng-model="model.value.required" />
	</div>
</umb-control-group>

You should now be able to go into your LeBlender properties editor and mark fields as required.

Hope this helps.

from leblender.

jacklawry avatar jacklawry commented on July 17, 2024

This is now working thanks @tomeglenn!

from leblender.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.