001/* 002 * Copyright 2016 Anyware Services 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.ametys.web.clientsideelement; 017 018import java.util.List; 019import java.util.Map; 020 021import org.apache.avalon.framework.configuration.Configuration; 022import org.apache.avalon.framework.configuration.ConfigurationException; 023 024import org.ametys.core.ui.AddTaskClientSideElement; 025 026/** 027 * This implementation creates an site-selection aware element for adding a new task which need a site parameter (called 'siteName') 028 */ 029public class SiteSelectionAwareAddTaskClientSideElement extends AddTaskClientSideElement 030{ 031 @Override 032 protected String _configureClass(Configuration configuration) throws ConfigurationException 033 { 034 return "Ametys.plugins.web.site.SiteSelectionAwareAddTaskButtonController"; 035 } 036 037 @Override 038 protected Map<String, Object> configureInitialParameters(Configuration configuration) throws ConfigurationException 039 { 040 Map<String, Object> initialParameters = super.configureInitialParameters(configuration); 041 initialParameters.put("action", "Ametys.plugins.web.site.SiteSelectionAwareAddTaskButtonController.act"); 042 initialParameters.put("selection-target-id", "^site$"); 043 initialParameters.put("selection-enable-multiselection", "false"); 044 return initialParameters; 045 } 046 047 @Override 048 protected Script _configureScript(Configuration configuration) throws ConfigurationException 049 { 050 List<ScriptFile> scriptsImports = _configureImports(configuration.getChild("scripts")); 051 scriptsImports.add(new ScriptFile("all", "all", "/plugins/core/resources/js/Ametys/plugins/core/schedule/Scheduler.js")); 052 scriptsImports.add(new ScriptFile("all", "all", "/plugins/core-ui/resources/js/Ametys/plugins/coreui/schedule/AddTaskButtonController.js")); 053 scriptsImports.add(new ScriptFile("all", "all", "/plugins/web/resources/js/Ametys/plugins/web/site/SiteSelectionAwareAddTaskButtonController.js")); 054 List<ScriptFile> cssImports = _configureImports(configuration.getChild("css")); 055 String jsClassName = _configureClass(configuration.getChild("class")); 056 Map<String, Object> initialParameters = configureInitialParameters(configuration); 057 058 return new Script(this.getId(), jsClassName, scriptsImports, cssImports, initialParameters); 059 } 060}