Skip to content

Commit

Permalink
Migrate standalone controllers in pages to component directives. (opp…
Browse files Browse the repository at this point in the history
…ia#6907)

* Rename and files about page

* Convert to component directive about page

* About Page

Fix lint

Fix lint

* Modify controller

* renaming and files creator dashboard

* Wrap up creator dashboard

* Donate page

* Fix backend tests and about -> about-page, creator-dashboard -> creator-dashboard-page

* Email Dashboard

* Email dashboard Result

* Lint

* Modify

* Wrap up

* Wrap up topic landing

* Lint

* Change .directive -> .controller for about page

* Change .directive -> .controller for creator dashboard and donate

* Fix backend topic editor

* .directive -> .controller email dashboard pages

* Stewards landing page

* Leaner dashboard

* Fix backend

* Fix lint

* Correct path

* Moderator page

* Notifications Dashboard page

* Preferences page

* Practice session page

* Splash page

* RE-added the backend test

* Revert "Practice session page"

This reverts commit 26713bd.

* Fix e2e in preferences

* Revert "Revert "Practice session page""

This reverts commit bfa7107.

* removed

* Modify imports

* Modify imports

* Modify imports

* Modify imports

* .directive -> .controller error-page

* Merge conflicts

* Fix merge
  • Loading branch information
YashJipkate authored and nithusha21 committed Jun 17, 2019
1 parent dbf87e0 commit 9b5d43d
Show file tree
Hide file tree
Showing 60 changed files with 6,647 additions and 6,153 deletions.
10 changes: 5 additions & 5 deletions core/controllers/custom_landing_pages_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def test_invalid_topic_landing_page_leads_to_404(self):

def test_valid_subject_and_topic_loads_correctly(self):
response = self.get_html_response('/learn/maths/fractions')
response.mustcontain('students and kids')
response.mustcontain('<topic-landing-page></topic-landing-page>')


class StewardsLandingPageTest(test_utils.GenericTestBase):
Expand All @@ -67,20 +67,20 @@ def test_nonprofits_landing_page(self):
response = self.get_html_response(
feconf.CUSTOM_NONPROFITS_LANDING_PAGE_URL)
response.mustcontain(
'Let\'s work together to make compelling educational')
'<stewards-landing-page></stewards-landing-page>')

def test_parents_landing_page(self):
response = self.get_html_response(
feconf.CUSTOM_PARENTS_LANDING_PAGE_URL)
response.mustcontain(
'Help your child learn with our free, engaging lessons')
'<stewards-landing-page></stewards-landing-page>')

def test_teachers_landing_page(self):
response = self.get_html_response(
feconf.CUSTOM_TEACHERS_LANDING_PAGE_URL)
response.mustcontain('Oppia\'s free, personalized lessons are a great')
response.mustcontain('<stewards-landing-page></stewards-landing-page>')

def test_volunteers_landing_page(self):
response = self.get_html_response(
feconf.CUSTOM_VOLUNTEERS_LANDING_PAGE_URL)
response.mustcontain('Help improve access to high-quality education')
response.mustcontain('<stewards-landing-page></stewards-landing-page>')
3 changes: 1 addition & 2 deletions core/controllers/pages_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ def test_about_page(self):
response = self.get_html_response('/about')
self.assertEqual(response.content_type, 'text/html')
response.mustcontain(
'I18N_ABOUT_PAGE_CREDITS_TAB_HEADING',
'I18N_ABOUT_PAGE_FOUNDATION_TAB_PARAGRAPH_5_LICENSE_HEADING')
'<about-page></about-page>')

def test_splash_page_with_valid_c_value(self):
response = self.get_html_response('/splash', params={'c': 'at0'})
Expand Down
158 changes: 85 additions & 73 deletions core/templates/dev/head/pages/about-page/about-page.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,91 +12,103 @@
// See the License for the specific language governing permissions and
// limitations under the License.

require('base_components/BaseContentDirective.ts');
/**
* @fileoverview Controllers for the about page.
*/

require(
'components/common-layout-directives/common-elements/' +
'background-banner.directive.ts');

require('domain/utilities/UrlInterpolationService.ts');

/**
* @fileoverview Controllers for the about page.
*/

oppia.controller('About', [
'$scope', '$window', 'UrlInterpolationService',
function($scope, $window, UrlInterpolationService) {
// Define constants
$scope.TAB_ID_ABOUT = 'about';
$scope.TAB_ID_FOUNDATION = 'foundation';
$scope.TAB_ID_CREDITS = 'credits';
oppia.directive('aboutPage', ['UrlInterpolationService',
function(UrlInterpolationService) {
return {
restrict: 'E',
scope: {},
bindToController: {},
templateUrl: UrlInterpolationService.getDirectiveTemplateUrl(
'/pages/about-page/about-page.directive.html'),
controllerAs: '$ctrl',
controller: [
'$window', 'UrlInterpolationService',
function($window, UrlInterpolationService) {
var ctrl = this;
// Define constants
ctrl.TAB_ID_ABOUT = 'about';
ctrl.TAB_ID_FOUNDATION = 'foundation';
ctrl.TAB_ID_CREDITS = 'credits';

var activeTabClass = 'oppia-about-tabs-active';
var hash = window.location.hash.slice(1);
var visibleContent = 'oppia-about-visible-content';
var activeTabClass = 'oppia-about-tabs-active';
var hash = window.location.hash.slice(1);
var visibleContent = 'oppia-about-visible-content';

var activateTab = function(tabName) {
$("a[id='" + tabName + "']").parent().addClass(
activeTabClass
).siblings().removeClass(activeTabClass);
$('.' + tabName).addClass(visibleContent).siblings().removeClass(
visibleContent
);
};
var activateTab = function(tabName) {
$("a[id='" + tabName + "']").parent().addClass(
activeTabClass
).siblings().removeClass(activeTabClass);
$('.' + tabName).addClass(visibleContent).siblings().removeClass(
visibleContent
);
};

if (hash === $scope.TAB_ID_FOUNDATION || hash === 'license') {
activateTab($scope.TAB_ID_FOUNDATION);
}
if (hash === ctrl.TAB_ID_FOUNDATION || hash === 'license') {
activateTab(ctrl.TAB_ID_FOUNDATION);
}

if (hash === $scope.TAB_ID_CREDITS) {
activateTab($scope.TAB_ID_CREDITS);
}
if (hash === ctrl.TAB_ID_CREDITS) {
activateTab(ctrl.TAB_ID_CREDITS);
}

if (hash === $scope.TAB_ID_ABOUT) {
activateTab($scope.TAB_ID_ABOUT);
}
if (hash === ctrl.TAB_ID_ABOUT) {
activateTab(ctrl.TAB_ID_ABOUT);
}

window.onhashchange = function() {
var hashChange = window.location.hash.slice(1);
if (hashChange === $scope.TAB_ID_FOUNDATION || hashChange === 'license') {
activateTab($scope.TAB_ID_FOUNDATION);
// Ensure page goes to the license section
if (hashChange === 'license') {
$window.location.reload(true);
}
} else if (hashChange === $scope.TAB_ID_CREDITS) {
activateTab($scope.TAB_ID_CREDITS);
} else if (hashChange === $scope.TAB_ID_ABOUT) {
activateTab($scope.TAB_ID_ABOUT);
}
};
window.onhashchange = function() {
var hashChange = window.location.hash.slice(1);
if (hashChange === ctrl.TAB_ID_FOUNDATION || (
hashChange === 'license')) {
activateTab(ctrl.TAB_ID_FOUNDATION);
// Ensure page goes to the license section
if (hashChange === 'license') {
$window.reload(true);
}
} else if (hashChange === ctrl.TAB_ID_CREDITS) {
activateTab(ctrl.TAB_ID_CREDITS);
} else if (hashChange === ctrl.TAB_ID_ABOUT) {
activateTab(ctrl.TAB_ID_ABOUT);
}
};

var listOfNamesToThank = [
'Alex Kauffmann', 'Allison Barros',
'Amy Latten', 'Brett Barros',
'Crystal Kwok', 'Daniel Hernandez',
'Divya Siddarth', 'Ilwon Yoon',
'Jennifer Chen', 'John Cox',
'John Orr', 'Katie Berlent',
'Michael Wawszczak', 'Mike Gainer',
'Neil Fraser', 'Noah Falstein',
'Nupur Jain', 'Peter Norvig',
'Philip Guo', 'Piotr Mitros',
'Rachel Chen', 'Rahim Nathwani',
'Robyn Choo', 'Tricia Ngoon',
'Vikrant Nanda', 'Vinamrata Singal',
'Yarin Feigenbaum'];
var listOfNamesToThank = [
'Alex Kauffmann', 'Allison Barros',
'Amy Latten', 'Brett Barros',
'Crystal Kwok', 'Daniel Hernandez',
'Divya Siddarth', 'Ilwon Yoon',
'Jennifer Chen', 'John Cox',
'John Orr', 'Katie Berlent',
'Michael Wawszczak', 'Mike Gainer',
'Neil Fraser', 'Noah Falstein',
'Nupur Jain', 'Peter Norvig',
'Philip Guo', 'Piotr Mitros',
'Rachel Chen', 'Rahim Nathwani',
'Robyn Choo', 'Tricia Ngoon',
'Vikrant Nanda', 'Vinamrata Singal',
'Yarin Feigenbaum'];

$scope.onTabClick = function(tabName) {
// Update hash
window.location.hash = '#' + tabName;
activateTab(tabName);
ctrl.onTabClick = function(tabName) {
// Update hash
window.location.hash = '#' + tabName;
activateTab(tabName);
};
ctrl.listOfNames = listOfNamesToThank
.slice(0, listOfNamesToThank.length - 1).join(', ') +
' & ' + listOfNamesToThank[listOfNamesToThank.length - 1];
ctrl.getStaticImageUrl = UrlInterpolationService.getStaticImageUrl;
ctrl.aboutPageMascotImgUrl = UrlInterpolationService
.getStaticImageUrl('/general/about_page_mascot.png');
}
]
};
$scope.listOfNames = listOfNamesToThank
.slice(0, listOfNamesToThank.length - 1).join(', ') +
' & ' + listOfNamesToThank[listOfNamesToThank.length - 1];
$scope.getStaticImageUrl = UrlInterpolationService.getStaticImageUrl;
$scope.aboutPageMascotImgUrl = UrlInterpolationService.getStaticImageUrl(
'/general/about_page_mascot.png');
}
]);
}]);
Loading

0 comments on commit 9b5d43d

Please sign in to comment.