I try to create a new page inside dashboard designer jaggery application in Data Analytic Server (DAS) of wso2. For this purpose I add in /themes/template a new template, in this case delete-gadget.jag, I add a new controller in /controllers with the same name delete-gadget.jag. In /themes/template I update the index.jag and add a new link for the delete-gaget.jag. When clicked this link the application say 404.
This is my code:
in /controllers/delete-gadget.jag:
<%
(function() {
if (!user) {
sendLogin();
return;
}
if(userDomain !== (urlDomain || superDomain)) {
response.sendError(401, 'designer access not authorized of this tenant');
return;
}
var configs = require('/configs/designer.json');
if (!utils.allowed(user.roles, configs.designers)) {
response.sendError(401, 'designer access not authorized');
return;
}
include(utils.resolvePath('templates/delete-gadget.jag'));
} ()); %>
Add the new link in /themes/template/index.jag:
<li><a href="<%=tenantedUrlPrefix%>delete-gadget">
<span class="fw-stack">
<i class="fw fw-ring fw-stack-2x"></i>
<i class="fw fw-delete fw-stack-1x"></i>
</span> <%= i18n.localize("delete.gadget.lable")%></a>
</li>
When I clik in this link:
You need to add the route definition on the jaggery.conf file at the root folder of the jaggery application. In your case is the file <WSO2DAS_HOME>/repository/deployment/server/jaggeryapps/portal/jaggery.conf. I recommend you start by duplicating the entry for creating a new gadget and then making the relevant changes. In your case it will be adding on the urlMappings list the following item:
{
"url": "/create-gadget",
"path": "/routers/tenant.jag"
},
Related
I am trying to make Django and React to work together, and although I have a basic knowledge of Django (I can develop a site), I am just starting to learn React.
My project structure is based on this video which is loosely based on this blog in turn.
My API works perfectly fine, I can create, retrieve, update, and delete objects without problems.
Also, on my frontend, I have managed to correctly display a list of the items from my database, by fetching the related API Url.
Just to make it clear, here is the main 'backend' urls.py:
from rest_framework import routers
from .views import AssessmentViewSet
router = routers.DefaultRouter()
router.register('api/assessments', AssessmentViewSet, 'assessments')
urlpatterns = router.urls
Now, from what I see on my API webpage, objects are created and retrieved on the same Url, and namely http://127.0.0.1:8000/api/assessments/, as you can see from this screenshot.
The only difference, I guess, is that when I want to create an object, all I have to do ist to specify inside the fetch function, that I am making a POST request. This is done in my CreateAssessmentForm.jsx file:
import React, { Component } from "react";
class CreateAssessmentForm extends Component {
state = {
loading: false,
title: "",
is_finished: false,
created_at: "",
};
constructor(props) {
super(props);
this.handleChange = this.handleChange.bind(this);
this.handleSubmit = this.handleSubmit.bind(this);
}
handleChange(event) {
let value = event.target.value;
console.log("Value: ", value);
this.setState({
title: value,
});
}
handleSubmit(event) {
event.preventDefault(console.log("Item:", this.state));
fetch("http://127.0.0.1:8000/api/assessments", {
method: "POST",
headers: {
"Content-type": "application/json",
},
body: JSON.stringify(this.state.title),
}).then(response => {
this.setState({
loading: false,
title: "",
is_finished: false,
created_at: "",
}).catch(function (error) {
console.log("ERROR:", error);
});
});
}
render() {
return (
<div>
{this.state.loading ? (
<div className="text-center">Loading...</div>
) : (
<form onSubmit={this.handleSubmit} method="POST">
<h2 className="text-center">Assessment Title</h2>
<div className="form-group">
<label htmlFor="Title">Title</label>
<input
onChange={this.handleChange}
type="text"
className="form-control"
id="TitleInput"
value={this.state.title}
placeholder="E.g. History Quiz"
/>
</div>
<button type="submit" className="btn btn-primary">
Submit
</button>
</form>
)}
</div>
);
}
}
export default CreateAssessmentForm;
When I type something inside the title input, the console logs properly every entry, and when I press the submit button it also logs an object (which as you can see from the code above is my actual state - {this.state}).
The problem is that when submitting, I get a 500 (Internal Server Error) and the object is not saved on the backend database.
Does anyone know what I am doing wrong?
Best shot would be to check what are the django logs as you get Internal Server Error. It should be clear enough of what you are doing wrong, if not, please post the error log.
on load of new route the active class not switching to new tab. I am not able to find the solution for this.
but the new page is loading without any issue. the only issue is the active class not switching to new page and not remove from the old page.
how to fix this?
here is my hbs file :
<div class="navbar-sub-header navbar-sub-header---tab-bar" style="border:1px solid red;">
<div class="rdc-tab-bar">
{{#link-to "auth-page.credit-card.credit-cardno" class="rdc-tab-bar___tab"}}
Credit Card //by default active added
{{/link-to}}
{{#link-to "auth-page.i-banking" class="rdc-tab-bar___tab"}}
Online Baning //when click page loads, active not swithing
{{/link-to}}
</div>
</div>
my router.js :
this.route('auth-page', function() {
this.route('credit-card', function() {
this.route('credit-cardno');
this.route('credit-otp'); //works fine
});
this.route('i-banking'); //not updating to active state
});
UDATE
When I directly hit the url as : http://localhost:4302/auth-page/i-banking I am getting active class updated.
I am currently working within SharePoint 2013 and was wondering if there was a way to create a button on a home page that when pressed, opens a list form in a modal window? (or in a non modal window).
I understand the method of using "Embed code" to code a button; however, it doesn't seem to allow me to link it to a list form, or edit what the button actually does.
Example:
1. An employee lands on the home page and wants to initiate a Purchase Request through the company.
2. The employee clicks on a button labeled "Click here to submit a Purchase Request".
3. After clicking, the Purchase Request form opens from the Purchase Request list (pre-created).
Thank you for your assistance!
You can use something like this in a CEWP to redirect to the new item form:
<button onclick="formRedirect(); return false;">New Form</button>
<script>
function formRedirect() {
window.location = "/test/Lists/LinkList/NewForm.aspx"
}
</script>
To display it in Modal form you will need to use the NewItem2 JS function:
<button onclick="NewItem2(event, "https://Your.SP.Site/_layouts/15/listform.aspx?PageType=8&ListId=%7B59E6FE0C%2D02C6%2D4B00%2D9B6A%2D87116A2DF594%7D&RootFolder="); return false;">New Form</button>
To get this to work you will need the list web part on the page where the button is located, though it can be hidden from view by setting th chrome to none and minimizing it. You can copy the function from the new item button in the list you wish to display, it is stored as an 'OnClick' property.
I know I am late to this but I just figured how to do this for the "Upload Document" for a document library. It took me a while but I stumbled upon it through trial and error using F12. I will provide both script for a "LIST and LIBRARY" form.
FOR A LIST:
<a href="#" onclick="openDialog('YourSiteURL/Lists/YourListName/NewForm.aspx');">
<img src="YourSiteImageURL" alt="NameofYourImage">
</a>
<script>
function openDialog(pageUrl) {
var options = {
url: pageUrl,
title: 'NameofYourForm', /* Enter the name you want for your form */
allowMaximize: false,
showClose: true,
width: 1225, /* Modify for your needs */
height: 800 /* Modify for your needs */
};
SP.SOD.execute('sp.ui.dialog.js', 'SP.UI.ModalDialog.showModalDialog', options);
}
</script>
FOR A LIBRARY:
This is for use with a button:
<a class="ms-addnew" id="idHomePageNewDocument" onclick='NewItem2(event, "YourSiteURL/_layouts/15/Upload.aspx?List={YourListID}&RootFolder="); return false;' href="YourSiteURL/_layouts/15/Upload.aspx?List={SameListID}&RootFolder=" target="_self" data-viewctr="702">
<img src="URLforYourButtonImage" alt="NameofYourButton">
</a>
This is for use with text:
<a class="ms-addnew" id="idHomePageNewDocument" onclick='NewItem2(event, "YourSiteURL/_layouts/15/Upload.aspx?List={YourListID}&RootFolder="); return false;' href="YourSiteURL/_layouts/15/Upload.aspx?List={SameListID}&RootFolder=" target="_self" data-viewctr="702">Add document
</a>
I am working on Sitecore MVC controller. I have created a controller “EventController” that have two actions “AllEvents” and [HttpPost] “SelectedYear” , one view “\Views\Event\AllEvents.cshtml”
“AllEvents” is attached with Sitecore controller rendering when I do publish preview from the content item page is loading with data and there is no problem. “All Events” page have a dropdown
When I click on selected year the post back is going but the view is not loading as required and losing the RenderingContext also. The url is going to hit http://testPage/api/Event/SelectedYear and image and css are not loading but data is there.
Below I have shared the sample code.
Please help me to fix the issue.
AllEvents.cshtml
<div>
#using (Html.BeginForm("SelectedYear", "Event", FormMethod.Post, new { id = "TheForm"}))
{
#Html.DropDownListFor(model => model.SelectedYear, Model.mapLocationItemTypes, "-- Select Status --", new { id = "CategoryID" })
}
</div>
SelectedYear Action
[HttpPost]
public ActionResult SelectedYear()
return View(eventCalender);
<script type="text/javascript">
$(function () {
alert("HSecond")
$("#CategoryID").change(function () {
$('#TheForm').submit();
});
});
</script>
RouteConfig
routes.MapRoute(
name: "Default",
url: "api/{controller}/{action}/{id}",
defaults: new { controller = "home", action = "index", id = UrlParameter.Optional }
In your Html.BeginForm() you specify the controller and the action to post to. But in fact, you want to post to the same Url, load the same Item and call the [HttpPost] action instead. This is a little different between ASP.net MVC and Sitecore MVC. I've written a blog post on how to handle form posts with Sitecore MVC:
http://ctor.io/posting-forms-in-sitecore-controller-renderings-another-perspective/
Also I had a presentation about Sitecore MVC at the SUGCON this year where posting forms was a topic. You may also want to look at the slides or the screencast
I have the need to act on the HTML element which triggers an Ember action.
The scenario is simple, let's say I have multiple rows of items, each having an action that pulls some data via an ajax. I want to disable that particular element until the ajax request has completed.
I checked this property but it refers to the Component Class.
So in the below markup, I'd like to capture the element in my component class.
<td><button {{action 'cancel' transaction}} class="btn-danger btn">Cancel</button></td>
There is not a default way to disable actions in Ember.
You could do it in several ways:
1) With CSS and bound controller properties.
a.is-inactive {
pointer-events: none;
cursor: default;
}
Then you must bind the className to the controller property (Inactive).
<a {{action 'cancel'}} {{bind-attr class="isInactive:is-inactive"}}
2) You could check in your route action that your actions is disabled. Use any specific controller to save the application state.
cancel: function() {
var controller = this.controller;
if ( controller.get('pendingAction') ) return;
controller.set('pendingAction', true);
this.ajax(...., function() {
....
controller.set('pendingAction', false);
}, function() {
....
controller.set('pendingAction', false);
});
}
3) Built your own way..
I have discussed this case at the discourse forum.